woof this was a big change but ok

Add cell_px everywhere we have dpi

This might be smelly. Sorry, Mr. Fowler and Prof. Frens...
This commit is contained in:
Andy Meneely
2020-11-17 23:40:15 -05:00
parent 24c9fbd0bf
commit 93a0d56eda
20 changed files with 100 additions and 70 deletions
+3 -2
View File
@@ -55,7 +55,8 @@ describe Squib::Args::Box do
context 'layouts' do
let(:deck_of_2) do
OpenStruct.new(width: 123, height: 456, size: 2, layout: {
OpenStruct.new(width: 123, height: 456, size: 2,
dpi: 300, cell_px: 37.5, layout: {
'attack' => { 'x' => 50 },
'defend' => { 'x' => 60 },
})
@@ -100,7 +101,7 @@ describe Squib::Args::Box do
end
context 'unit conversion' do
let(:deck_of_2) { OpenStruct.new(width: 123, height: 456, size: 2, dpi: 300) }
let(:deck_of_2) { OpenStruct.new(width: 123, height: 456, size: 2, dpi: 300, cell_px: 37.5) }
it 'converts units on all args' do
args = { x: ['1in', '2in'], y: 300, width: '1in', height: '1in' }
+1 -1
View File
@@ -50,7 +50,7 @@ describe Squib::Args::Draw do
it 'does unit conversion on dash options' do
args = { dash: '3in 4in 5in' }
draw.load!(args)
draw.load!(args, dpi: 300)
expect(draw).to have_attributes(dash: [[900, 1200, 1500]])
end
+10 -10
View File
@@ -3,7 +3,7 @@ require 'squib/sprues/sprue'
describe Squib::Sprue do
it 'loads a sprue' do
tmpl = Squib::Sprue.load(sprue_file('basic.yml'), 100)
tmpl = Squib::Sprue.load(sprue_file('basic.yml'), 100, 37.5)
expect(tmpl.sheet_width).to eq(850)
expect(tmpl.sheet_height).to eq(1100)
expect(tmpl.card_width).to eq(250)
@@ -23,7 +23,7 @@ describe Squib::Sprue do
end
it 'loads from the default templates if none exists' do
tmpl = Squib::Sprue.load('a4_poker_card_9up.yml', 100)
tmpl = Squib::Sprue.load('a4_poker_card_9up.yml', 100, 37.5)
expect(tmpl.sheet_width).to eq(826.7716527)
expect(tmpl.sheet_height).to eq(1169.2913373899999)
expect(tmpl.card_width).to eq(248.03149580999997)
@@ -84,7 +84,7 @@ describe Squib::Sprue do
end
it 'loads a template with the coordinates specifying the middle of cards' do
tmpl = Squib::Sprue.load(sprue_file('card_center_coord.yml'), 100)
tmpl = Squib::Sprue.load(sprue_file('card_center_coord.yml'), 100, 37.5)
expect(tmpl.sheet_width).to eq(850)
expect(tmpl.sheet_height).to eq(1100)
expect(tmpl.card_width).to eq(200)
@@ -101,7 +101,7 @@ describe Squib::Sprue do
end
it 'loads a template with customized crop lines' do
tmpl = Squib::Sprue.load(sprue_file('custom_crop_lines.yml'), 100)
tmpl = Squib::Sprue.load(sprue_file('custom_crop_lines.yml'), 100, 37.5)
expect(tmpl.sheet_width).to eq(850)
expect(tmpl.sheet_height).to eq(1100)
expect(tmpl.card_width).to eq(200)
@@ -137,7 +137,7 @@ describe Squib::Sprue do
end
it 'loads a template with rotated cards' do
tmpl = Squib::Sprue.load(sprue_file('card_rotation.yml'), 100)
tmpl = Squib::Sprue.load(sprue_file('card_rotation.yml'), 100, 37.5)
expect(tmpl.sheet_width).to eq(850)
expect(tmpl.sheet_height).to eq(1100)
expect(tmpl.card_width).to eq(250)
@@ -151,7 +151,7 @@ describe Squib::Sprue do
end
it 'loads a template with flipped cards' do
tmpl = Squib::Sprue.load(sprue_file('card_flip.yml'), 100)
tmpl = Squib::Sprue.load(sprue_file('card_flip.yml'), 100, 37.5)
expect(tmpl.cards.length).to eq(3)
expect(tmpl.cards.map { |card| card['flip_vertical'] })
.to eq( [false, true, false] )
@@ -161,7 +161,7 @@ describe Squib::Sprue do
it 'fails when sheet_width is not defined' do
expect do
Squib::Sprue.load(sprue_file('fail_no_sheet_width.yml'), 100)
Squib::Sprue.load(sprue_file('fail_no_sheet_width.yml'), 100, 37.5)
end.to raise_error(
Squib::Sprues::InvalidSprueDefinition,
include('"sheet_width" is not a String matching /^(\d*[.])?\d+(in|cm|mm)$/')
@@ -170,7 +170,7 @@ describe Squib::Sprue do
it 'fails when sheet_height is not defined' do
expect do
Squib::Sprue.load(sprue_file('fail_no_sheet_height.yml'), 100)
Squib::Sprue.load(sprue_file('fail_no_sheet_height.yml'), 100, 37.5)
end.to raise_error(
Squib::Sprues::InvalidSprueDefinition,
include('"sheet_height" is not a String matching /^(\d*[.])?\d+(in|cm|mm)$/')
@@ -179,7 +179,7 @@ describe Squib::Sprue do
it 'fails when card_width is not defined' do
expect do
Squib::Sprue.load(sprue_file('fail_no_card_width.yml'), 100)
Squib::Sprue.load(sprue_file('fail_no_card_width.yml'), 100, 37.5)
end.to raise_error(
Squib::Sprues::InvalidSprueDefinition,
include('"card_width" is not a String matching /^(\d*[.])?\d+(in|cm|mm)$/')
@@ -188,7 +188,7 @@ describe Squib::Sprue do
it 'fails when card_height is not defined' do
expect do
Squib::Sprue.load(sprue_file('fail_no_card_height.yml'), 100)
Squib::Sprue.load(sprue_file('fail_no_card_height.yml'), 100, 37.5)
end.to raise_error(
Squib::Sprues::InvalidSprueDefinition,
include('"card_height" is not a String matching /^(\d*[.])?\d+(in|cm|mm)$/')