Documented a range idiom

In reaction to #90

[skip ci]
This commit is contained in:
Andy Meneely
2015-07-03 16:01:44 -04:00
parent 79814a43ea
commit 2dd3fc3365
5 changed files with 14 additions and 2 deletions
+12 -1
View File
@@ -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