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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
# File 'lib/punks/bodies_32.rb', line 47
def self.generate( *values, patch: nil )
attributes = []
archetype_name = values[0]
if archetype_name.is_a?( Pixelart::Image )
archetype = archetype_name
attributes << archetype
attribute_gender = 'm'
attribute_size = 'l'
elsif patch && img=patch[ Sheet.normalize_key(archetype_name) ]
archetype = img
attributes << archetype
if archetype_name.downcase.index( 'female' )
attribute_gender = 'f'
attribute_size = 's'
else
attribute_gender = 'm'
attribute_size = 'l'
end
else archetype = Sheet.find_meta_by( name: archetype_name )
if archetype.nil?
puts "!! ERROR - archetype >#{archetype}< not found; sorry"
exit 1
end
attributes << Sheet.image[ archetype.id ]
attribute_gender = archetype.gender
attribute_size = archetype.size
end
attribute_names = values[1..-1]
attribute_names.each do |attribute_name|
if attribute_name.is_a?( Pixelart::Image )
attributes << attribute_name
elsif patch && img=patch[ Sheet.normalize_key(attribute_name) ]
attributes << img
else
attribute = Sheet.find_by( name: attribute_name,
gender: attribute_gender,
size: attribute_size,
warn: false )
attribute = Punk::Sheet.find_by( name: attribute_name,
gender: attribute_gender,
size: attribute_size ) if attribute.nil?
if attribute.nil?
puts "!! ERROR - attribute >#{attribute_name}< for (#{attribute_gender}+#{attribute_size}) not found; sorry"
exit 1
end
attributes << attribute
end
end
punk = new( 32, 32 )
attributes.each do |attribute|
if attribute.width == 24 && attribute.height == 24
attribute = attribute.crop( 0, 1, 24, 23 )
punk.compose!( attribute, 6, 0 )
elsif attribute.width == 32 && attribute.height == 32
punk.compose!( attribute )
else
puts "!! ERROR - unsupported attribute size; got #{attribute.width}x#{attribute.height} - expected 32x32 or 24x24; sorry"
exit 1
end
end
punk
end
|