Skip to content

Instantly share code, notes, and snippets.

@andymeneely
Last active April 26, 2016 13:41
Show Gist options
  • Save andymeneely/6f68e069b9469ce2b00e343cc9db18a9 to your computer and use it in GitHub Desktop.
Save andymeneely/6f68e069b9469ce2b00e343cc9db18a9 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
require 'squib'
def use_red? i, j
(5 * i + j) % 2 == 0
end
## Should be 512 cards
nc = 20
dko = (['k'] * 1) +
(['s'] * 1) +
(['r'] * 8) +
(['b'] * 8) +
(['w'] * 7)
dka = []
nc.times { dka.push(dko.shuffle) }
dka = dka.transpose
Squib::Deck.new(width: 897, height: 897, cards: nc) do
background color: '#ffFFFFFF'
#data = xlsx file: 'randgrid.xlsx', sheet: 0
#background color: '#AAAAAA'
strks = []
for i in 0..4 do
for j in 0..4 do
x = 73 + 150 * i
y = 73 + 150 * j
# starting player selection
if use_red? i, j
strt = "r"
strks.push(:red)
else
strt = "b"
strks.push(:blue)
end
# Replace "s" with the correct color
# data["pos#{i}#{j}"]=data["pos#{i}#{j}"].map! {|a| a=="s" ? strt : a}
dk = dko.shuffle.map { |a| a=="s" ? strt : a}
dk = dk.map { |a| "#{a}.png" }
#data["pos#{i}#{j}"]=data["pos#{i}#{j}"].map { |c| "#{c}.png" }
#png file: data["pos#{i}#{j}"], x: x, y: y
png file: dk, x: x, y: y
end
end
# rect x: 36, y: 36, width: 825, height: 825, radius: 10, stroke_color: :black
v = 8
rect x: 72-v, y: 72-v, width: 753+2*v, height: 753+2*v, radius: 20, stroke_width: 20,
stroke_color: strks, stroke_strategy: :fill_first
save prefix: 'g', format: :png
#hand file: 'showcase.png', trim: 10, trim_radius: 25, fill_color: '#DDDDDD'
end
puts "---"
puts dko
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment