Browse Source

Documented a range idiom

In reaction to #90

[skip ci]
dev
Andy Meneely 11 years ago
parent
commit
2dd3fc3365
  1. 3
      CHANGELOG.md
  2. 13
      samples/ranges.rb
  3. BIN
      spec/samples/expected/ranges_00.png
  4. BIN
      spec/samples/expected/ranges_01.png
  5. BIN
      spec/samples/expected/ranges_02.png

3
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.

13
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

BIN
spec/samples/expected/ranges_00.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 46 KiB

BIN
spec/samples/expected/ranges_01.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

BIN
spec/samples/expected/ranges_02.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Loading…
Cancel
Save