-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest1
53 lines (35 loc) · 1.17 KB
/
test1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
require 'pixelart'
slug = 'diyordibots-v2'
slug_spritesheet = 'diyordibots'
width = 32
height = 32
max = 999
grid = [40,25] ## 40 cols x 25 rows = 1000
recs = read_csv( "./#{slug}/mint.csv" )
puts " #{recs.size} record(s)"
# cut-down to max. limit
recs = recs[0, max]
puts " #{recs.size} record(s)"
spritesheet_path = if defined?( slug_spritesheet )
"./#{slug_spritesheet}/spritesheet.png"
else
"./#{slug}/spritesheet.png"
end
spritesheet = ImageComposite.read( spritesheet_path,
width: width,
height: height )
composite = ImageComposite.new( *grid, width: width,
height: height )
recs.each_with_index do |rec,i|
img = Image.new( width, height )
g = rec['g'].split( ' ' ).map {|v| v.to_i(10) }
puts "==> no. #{i} g: #{rec['g']} - #{g.inspect}"
g.each do |num|
img.compose!( spritesheet[ num ] )
end
composite << img
end
outname = "./tmp/#{slug}_max#{max}"
composite.save( "#{outname}.png" )
composite.zoom(4).save( "#{outname}@4x.png" )
puts "bye"