-
Notifications
You must be signed in to change notification settings - Fork 124
/
composite.rb
103 lines (66 loc) · 2.13 KB
/
composite.rb
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
###
# to run use:
# ruby ./composite.rb
require 'cryptopunks'
punks = Punks::Image::Composite.read( './punks.png' )
## load csv dataset for meta data
recs = Punks::Dataset.read( '../punks/*999.csv' )
puts " #{recs.size} punk metadata record(s)"
#=> 10000 punk metadata record(s)
aliens = recs.select {|rec| rec.alien? }
puts " #{aliens.size} alien metadata record(s)"
#=> 9
## 3x3 (=9) composite
composite = Punks::Image::Composite.new( 3, 3 )
aliens.each do |rec|
composite << punks[ rec.id ]
end
composite.save( "i/aliens.png" )
apes = recs.select {|rec| rec.ape? }
puts " #{apes.size} ape metadata record(s)"
#=> 24
## 4x6 (=24) composite
composite = Punks::Image::Composite.new( 4, 6 )
apes.each do |rec|
composite << punks[ rec.id ]
end
composite.save( "i/apes.png" )
zombies = recs.select {|rec| rec.zombie? }
puts " #{zombies.size} zombie metadata record(s)"
#=> 88
## 8x11 (=88) composite
composite = Punks::Image::Composite.new( 8, 11 )
zombies.each do |rec|
composite << punks[ rec.id ]
end
composite.save( "i/zombies.png" )
blondies = recs.select do |rec|
rec.female? &&
(rec.has?( 'Blonde Short' ) ||
rec.has?( 'Blonde Bob' ) ||
rec.has?( 'Wild Blonde') ||
rec.has?( 'Straight Hair Blonde'))
end
puts " #{blondies.size} blondie metadata record(s)"
#=> 564
## 25x23 (= max. 575) composite
composite = Punks::Image::Composite.new( 25, 23 )
blondies.each do |rec|
composite << punks[ rec.id ]
end
composite.save( "i/blondies.png" )
mohawks = recs.select do |rec|
rec.has?( 'Mohawk') ||
rec.has?( 'Mohawk Thin' ) ||
rec.has?( 'Mohawk Dark') ||
rec.has?( 'Red Mohawk' )
end
puts " #{mohawks.size} mohawk metadata record(s)"
#=> 1458
## 40x37 (= max. 1480) composite
composite = Punks::Image::Composite.new( 40, 37 )
mohawks.each do |rec|
composite << punks[ rec.id ]
end
composite.save( "i/mohawks.png" )
puts "bye"