Browse Source

rows arg in save_sheet is always respected

fixes #332
dev
Andy Meneely 5 years ago
parent
commit
f8c0e1b129
  1. 6
      CHANGELOG.md
  2. 11
      lib/squib/args/sheet.rb
  3. 10
      samples/saves/_saves.rb
  4. BIN
      samples/saves/save_sheet_bug332_00_expected.png
  5. 82
      spec/data/samples/saves/_saves.rb.txt

6
CHANGELOG.md

@ -1,6 +1,12 @@
# Squib CHANGELOG
Squib follows [semantic versioning](http://semver.org).
## v0.16.1 / Unreleased
Bugs:
* The `rows` argument is always respected in `save_sheet` (#332).
## v0.16.0 / 2020-11-24
Features:

11
lib/squib/args/sheet.rb

@ -82,14 +82,9 @@ module Squib::Args
def validate_rows(arg)
raise 'columns must be an integer' unless columns.respond_to? :to_i
count = if range == :all
@deck.size
else
count = range.to_a.length
end
return 1 if count <= columns
return arg if arg.respond_to? :to_i
(count.to_f / columns.to_f).ceil
count = (range == :all) ? @deck.size : count = range.to_a.length
return arg.to_i if arg.respond_to? :to_i
(count.to_f / columns.to_f).ceil # e.g. :infinite
end
def full_filename(i=nil)

10
samples/saves/_saves.rb

@ -50,3 +50,13 @@ Squib::Deck.new(width: 825, height: 1125, cards: 16) do
columns: 2, rows: 1,
margin: 75, gap: 5, trim: 37
end
Squib::Deck.new(width: 100, height: 100, cards: 3) do
background color: :grey
text str: 'Hi', font: 'Arial 18'
# Test bug 332.
# When we only have 3 cards but want a 2x4 grid with lots of empty spaces.
# Buggy behavior was to revert to 1 row and not respect the rows arg.
save_sheet prefix: 'save_sheet_bug332_', rows: 2, columns: 4
end

BIN
samples/saves/save_sheet_bug332_00_expected.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 793 B

82
spec/data/samples/saves/_saves.rb.txt

@ -1808,3 +1808,85 @@ surface: finish([])
surface: finish([])
surface: finish([])
surface: finish([])
cairo: antialias=(["subpixel"])
cairo: antialias=(["subpixel"])
cairo: antialias=(["subpixel"])
cairo: save([])
cairo: new_path([])
cairo: set_source_color(["grey"])
cairo: paint([])
cairo: restore([])
cairo: save([])
cairo: new_path([])
cairo: set_source_color(["grey"])
cairo: paint([])
cairo: restore([])
cairo: save([])
cairo: new_path([])
cairo: set_source_color(["grey"])
cairo: paint([])
cairo: restore([])
cairo: save([])
cairo: new_path([])
cairo: set_source_color(["black"])
cairo: translate([0, 0])
cairo: rotate([0])
cairo: move_to([0, 0])
pango: font_description=([MockDouble])
pango: text=(["Hi"])
pango: wrap=([#<Pango::WrapMode word-char>])
pango: ellipsize=([#<Pango::EllipsizeMode end>])
pango: alignment=([#<Pango::Alignment left>])
pango: justify=([false])
cairo: move_to([0, 0])
cairo: move_to([0, 0])
cairo: show_pango_layout([MockDouble])
pango: ellipsized?([])
pango: ellipsized?([])
cairo: restore([])
cairo: save([])
cairo: new_path([])
cairo: set_source_color(["black"])
cairo: translate([0, 0])
cairo: rotate([0])
cairo: move_to([0, 0])
pango: font_description=([MockDouble])
pango: text=(["Hi"])
pango: wrap=([#<Pango::WrapMode word-char>])
pango: ellipsize=([#<Pango::EllipsizeMode end>])
pango: alignment=([#<Pango::Alignment left>])
pango: justify=([false])
cairo: move_to([0, 0])
cairo: move_to([0, 0])
cairo: show_pango_layout([MockDouble])
pango: ellipsized?([])
pango: ellipsized?([])
cairo: restore([])
cairo: save([])
cairo: new_path([])
cairo: set_source_color(["black"])
cairo: translate([0, 0])
cairo: rotate([0])
cairo: move_to([0, 0])
pango: font_description=([MockDouble])
pango: text=(["Hi"])
pango: wrap=([#<Pango::WrapMode word-char>])
pango: ellipsize=([#<Pango::EllipsizeMode end>])
pango: alignment=([#<Pango::Alignment left>])
pango: justify=([false])
cairo: move_to([0, 0])
cairo: move_to([0, 0])
cairo: show_pango_layout([MockDouble])
pango: ellipsized?([])
pango: ellipsized?([])
cairo: restore([])
cairo: set_source([MockDouble, 0, 0])
cairo: paint([])
cairo: set_source([MockDouble, 100, 0])
cairo: paint([])
cairo: set_source([MockDouble, 200, 0])
cairo: paint([])
surface: write_to_png(["_output/save_sheet_bug332_00.png"])
surface: finish([])
surface: finish([])
surface: finish([])

Loading…
Cancel
Save