Implemented new args design for svg and png

As part of that implementation, text_embed now supports singleton expansion. Closes #54
This commit is contained in:
Andy Meneely
2015-07-21 20:27:15 -04:00
parent ff3d057d49
commit e20c644a9a
16 changed files with 253 additions and 112 deletions
+7 -7
View File
@@ -3,7 +3,7 @@ require 'squib/args/box'
describe Squib::Args::Box do
subject(:box) { Squib::Args::Box.new }
let(:expected_defaults) { {x: [0], y: [0], width: [:native], height: [:native] } }
let(:expected_defaults) { {x: [0], y: [0], width: [:deck], height: [:deck] } }
it 'intitially has no params set' do
expect(box).not_to respond_to(:x, :y, :width, :height)
@@ -16,7 +16,7 @@ describe Squib::Args::Box do
it 'extracts what is specified and fills in defaults from Box' do
box.load!(x: 4, width: 40)
expect(box).to have_attributes(x: [4], width: [40], y: [0], height: [:native])
expect(box).to have_attributes(x: [4], width: [40], y: [0], height: [:deck])
end
it 'extracts the defaults from Box on an empty hash' do
@@ -32,8 +32,8 @@ describe Squib::Args::Box do
expect(box).to have_attributes({
x: [1, 2],
y: [3, 3],
height: [:native, :native],
width: [:native, :native]
height: [:deck, :deck],
width: [:deck, :deck]
})
end
@@ -41,8 +41,8 @@ describe Squib::Args::Box do
expect(box[0]).to have_attributes({
x: 1,
y: 3,
height: :native,
width: :native
height: :deck,
width: :deck
})
end
end
@@ -98,7 +98,7 @@ describe Squib::Args::Box do
context 'validation' do
it 'replaces with deck width and height' do
args = {width: :native, height: :native}
args = {width: :deck, height: :deck}
deck = OpenStruct.new(width: 123, height: 456)
box = Squib::Args::Box.new(deck)
box.load!(args, expand_by: 1)
+2 -5
View File
@@ -240,7 +240,7 @@ cairo: set_source_color(["black"])
cairo: translate([0, 0])
cairo: rotate([0])
cairo: move_to([0, 0])
pango font: size=([32768])
pango font: size=([26624])
pango: font_description=([MockDouble])
pango: text=(["Take 1 :tool: and gain 2 :health:."])
pango: width=([184320])
@@ -265,7 +265,7 @@ cairo: set_source_color(["black"])
cairo: translate([0, 0])
cairo: rotate([0])
cairo: move_to([0, 0])
pango font: size=([46080])
pango font: size=([35840])
pango: font_description=([MockDouble])
pango: text=(["Take 1 :tool: and gain 2 :health:."])
pango: width=([184320])
@@ -285,9 +285,6 @@ cairo: set_source_color([:cyan])
cairo: set_line_width([2.0])
cairo: stroke([])
cairo: restore([])
surface: write_to_png(["_output/embed_multi_00.png"])
surface: write_to_png(["_output/embed_multi_01.png"])
surface: write_to_png(["_output/embed_multi_02.png"])
cairo: set_source([MockDouble, 0, 0])
cairo: paint([])
cairo: set_source([MockDouble, 100, 0])
+16
View File
@@ -221,6 +221,8 @@ cairo: rotate([0])
cairo: move_to([0, 0])
pango: font_description=([MockDouble])
pango: text=(["A"])
pango: width=([204800])
pango: height=([204800])
pango: wrap=([#<Pango::Layout::WrapMode word-char>])
pango: ellipsize=([#<Pango::Layout::EllipsizeMode end>])
pango: alignment=([#<Pango::Layout::Alignment left>])
@@ -238,6 +240,8 @@ cairo: rotate([0])
cairo: move_to([0, 0])
pango: font_description=([MockDouble])
pango: text=(["B"])
pango: width=([204800])
pango: height=([204800])
pango: wrap=([#<Pango::Layout::WrapMode word-char>])
pango: ellipsize=([#<Pango::Layout::EllipsizeMode end>])
pango: alignment=([#<Pango::Layout::Alignment left>])
@@ -255,6 +259,8 @@ cairo: rotate([0])
cairo: move_to([0, 0])
pango: font_description=([MockDouble])
pango: text=(["C"])
pango: width=([204800])
pango: height=([204800])
pango: wrap=([#<Pango::Layout::WrapMode word-char>])
pango: ellipsize=([#<Pango::Layout::EllipsizeMode end>])
pango: alignment=([#<Pango::Layout::Alignment left>])
@@ -272,6 +278,8 @@ cairo: rotate([0])
cairo: move_to([0, 0])
pango: font_description=([MockDouble])
pango: text=(["D"])
pango: width=([204800])
pango: height=([204800])
pango: wrap=([#<Pango::Layout::WrapMode word-char>])
pango: ellipsize=([#<Pango::Layout::EllipsizeMode end>])
pango: alignment=([#<Pango::Layout::Alignment left>])
@@ -289,6 +297,8 @@ cairo: rotate([0])
cairo: move_to([0, 0])
pango: font_description=([MockDouble])
pango: text=(["E"])
pango: width=([204800])
pango: height=([204800])
pango: wrap=([#<Pango::Layout::WrapMode word-char>])
pango: ellipsize=([#<Pango::Layout::EllipsizeMode end>])
pango: alignment=([#<Pango::Layout::Alignment left>])
@@ -306,6 +316,8 @@ cairo: rotate([0])
cairo: move_to([0, 0])
pango: font_description=([MockDouble])
pango: text=(["F"])
pango: width=([204800])
pango: height=([204800])
pango: wrap=([#<Pango::Layout::WrapMode word-char>])
pango: ellipsize=([#<Pango::Layout::EllipsizeMode end>])
pango: alignment=([#<Pango::Layout::Alignment left>])
@@ -323,6 +335,8 @@ cairo: rotate([0])
cairo: move_to([0, 0])
pango: font_description=([MockDouble])
pango: text=(["G"])
pango: width=([204800])
pango: height=([204800])
pango: wrap=([#<Pango::Layout::WrapMode word-char>])
pango: ellipsize=([#<Pango::Layout::EllipsizeMode end>])
pango: alignment=([#<Pango::Layout::Alignment left>])
@@ -340,6 +354,8 @@ cairo: rotate([0])
cairo: move_to([0, 0])
pango: font_description=([MockDouble])
pango: text=(["H"])
pango: width=([204800])
pango: height=([204800])
pango: wrap=([#<Pango::Layout::WrapMode word-char>])
pango: ellipsize=([#<Pango::Layout::EllipsizeMode end>])
pango: alignment=([#<Pango::Layout::Alignment left>])