-
Notifications
You must be signed in to change notification settings - Fork 123
/
Copy pathgenerate.rb
89 lines (72 loc) · 2.59 KB
/
generate.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
###
# to run use:
# ruby ./generate.rb
require 'pixelart'
PARTS = {
face: { required: true,
attributes: [['', 'u'],
['', 'u']] },
mouth: { required: true,
attributes: [['Black Lipstick', 'f'],
['Red Lipstick', 'f'],
['Smile', 'u'],
['', 'u'],
['Teeth Smile', 'm'],
['Purple Lipstick', 'f']] },
nose: { required: true,
attributes: [['', 'u'],
['Nose Ring', 'u']] },
eyes: { required: true,
attributes: [['', 'u'],
['Asian Eyes', 'u'],
['Sun Glasses', 'u'],
['Red Glasses', 'u'],
['Round Eyes', 'u']] },
ears: { required: true,
attributes: [['', 'u'],
['Left Earring', 'u'],
['Right Earring', 'u'],
['Two Earrings', 'u']] },
beard: { required: false,
attributes: [['Brown Beard', 'm'],
['Mustache-Beard', 'm'],
['Mustache', 'm'],
['Regular Beard', 'm']] },
hair: { required: false,
attributes: [['Up Hair', 'm'],
['Down Hair', 'u'],
['Mahawk', 'u'],
['Red Mahawk', 'u'],
['Orange Hair', 'u'],
['Bubble Hair', 'm'],
['Emo Hair', 'u'],
['Thin Hair', 'm'],
['Bald', 'm'],
['Blonde Hair', 'f']] }
}
def generate_punk( codes )
punk = Pixelart::Image.new( 56, 56 )
PARTS.each_with_index do |(key,part),i|
code = codes[i]
if code != 0
attribute = part[:attributes][ code-1 ]
puts "#{key}#{code} - #{attribute[0]} (#{attribute[1]})" if attribute[0].size > 0
path = "./i/parts/#{key}/#{key}#{code}.png"
part = Pixelart::Image.read( path )
punk.compose!( part )
end
end
punk
end
codes = [2, 2, 2, 3, 1, 0, 10]
punk = generate_punk( codes )
punk.save( "./tmp/punk-0000.png" )
punk3x = punk.zoom( 3 )
punk3x.save( "./tmp/punk-0000x3.png" )
puts "---"
codes = [1, 5, 2, 3, 1, 1, 5]
punk = generate_punk( codes )
punk.save( "./tmp/punk-0001.png" )
punk3x = punk.zoom( 3 )
punk3x.save( "./tmp/punk-0001x3.png" )
puts "bye"