diff --git a/CHANGELOG.md b/CHANGELOG.md index a106958..187ccb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,10 @@ Squib follows [semantic versioning](http://semver.org). ## v0.7.0 / Unreleased Features -* Added `cap` option to `line` `curve` to define how those ends are drawn +* Added `cap` option to `line` and `curve` to define how those ends are drawn * Added `join` option to all drawing operations (e.g. `rect`, `star`, even outlines for `text`) to define how corners are drawn. * Added `dash` option to all drawing operations (e.g. `rect`, `star`, even outlines for `text`) so you can specify your own dash pattern. Just specify a string with space-separated numbers to specify the on-and-off alternating pattern (e.g. `dash: '2 2'` with a stroke width of 2 is evenly spaced dots). Supports unit conversion (e.g. `dash: '0.02in 0.02in'`) +* Added an idiom to the `ranges.rb` sample for drawing a different number of images based on the column in a table (e.g. 2 arrows to indicate 2 actions). Based on question #90. There are probably even cleaner, Ruby-ish ways to do this too - pull requests are welcome. Compatibility: * All drawn shapes (e.g. circle, triangle, star) will now draw their stroke on top of the fill. This was not consistent before, and now it is (because Squib is more DRY about it!). This might mean that your `stroke_width` will render wider than before. diff --git a/samples/ranges.rb b/samples/ranges.rb index 08a808a..dd1a74b 100644 --- a/samples/ranges.rb +++ b/samples/ranges.rb @@ -49,5 +49,16 @@ Squib::Deck.new(width: 825, height: 1125, cards: 3) do str: 'Only for Thinkers!', x:25, y: 500 - save prefix: 'ranges_', format: :png + # Useful idiom: draw a different number of images for different cards + hearts = [nil, 1, 2] #i.e. card 0 has no hearts, card 2 has 2 hearts drawn + 1.upto(2).each do |n| + range = hearts.each_index.select { |i| hearts[i] == n} + n.times do |i| + svg file: 'glass-heart.svg', range: range, + x: 150, y: 55 + i*42, width: 40, height: 40 + end + end + + rect color: 'black' # just a border + save_sheet prefix: 'ranges_', columns: 3 end diff --git a/spec/samples/expected/ranges_00.png b/spec/samples/expected/ranges_00.png index 499d360..5f23a6c 100644 Binary files a/spec/samples/expected/ranges_00.png and b/spec/samples/expected/ranges_00.png differ diff --git a/spec/samples/expected/ranges_01.png b/spec/samples/expected/ranges_01.png deleted file mode 100644 index baafa98..0000000 Binary files a/spec/samples/expected/ranges_01.png and /dev/null differ diff --git a/spec/samples/expected/ranges_02.png b/spec/samples/expected/ranges_02.png deleted file mode 100644 index 87e7bf8..0000000 Binary files a/spec/samples/expected/ranges_02.png and /dev/null differ