moonbirds 0.1.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Manifest.txt +4 -3
- data/README.md +160 -45
- data/Rakefile +5 -4
- data/config/spritesheet-24x24.csv +222 -0
- data/config/spritesheet-24x24.png +0 -0
- data/config/spritesheet-42x42.csv +326 -0
- data/config/spritesheet-42x42.png +0 -0
- data/lib/moonbirds/version.rb +6 -2
- data/lib/moonbirds.rb +66 -32
- metadata +31 -16
- data/config/spritesheet.csv +0 -218
- data/config/spritesheet.png +0 -0
- data/lib/moonbirds/generator.rb +0 -190
data/config/spritesheet.csv
DELETED
@@ -1,218 +0,0 @@
|
|
1
|
-
id, name, type, more_names
|
2
|
-
0, body brave-brown, ?, brave-brown
|
3
|
-
1, body crescent-brown, ?, crescent-brown
|
4
|
-
2, body emperor-brown, ?, emperor-brown
|
5
|
-
3, body guardian-brown, ?, guardian-brown
|
6
|
-
4, body sage-brown, ?, sage-brown
|
7
|
-
5, body stark-brown, ?, stark-brown
|
8
|
-
6, body tabby-brown, ?, tabby-brown
|
9
|
-
7, body tranquil-brown, ?, tranquil-brown
|
10
|
-
8, body brave-red, ?, brave-red
|
11
|
-
9, body crescent-red, ?, crescent-red
|
12
|
-
10, body emperor-red, ?, emperor-red
|
13
|
-
11, body guardian-red, ?, guardian-red
|
14
|
-
12, body professor-red, ?, professor-red
|
15
|
-
13, body sage-red, ?, sage-red
|
16
|
-
14, body tabby-red, ?, tabby-red
|
17
|
-
15, body tranquil-red, ?, tranquil-red
|
18
|
-
16, body emperor-white, ?, emperor-white
|
19
|
-
17, body guardian-white, ?, guardian-white
|
20
|
-
18, body professor-white, ?, professor-white
|
21
|
-
19, body stark-white, ?, stark-white
|
22
|
-
20, body tabby-white, ?, tabby-white
|
23
|
-
21, body tranquil-white, ?, tranquil-white
|
24
|
-
22, body crescent-gray, ?, crescent-gray
|
25
|
-
23, body emperor-gray, ?, emperor-gray
|
26
|
-
24, body professor-gray, ?, professor-gray
|
27
|
-
25, body tabby-gray, ?, tabby-gray
|
28
|
-
26, body brave-black, ?, brave-black
|
29
|
-
27, body crescent-black, ?, crescent-black
|
30
|
-
28, body emperor-black, ?, emperor-black
|
31
|
-
29, body stark-black, ?, stark-black
|
32
|
-
30, body tranquil-black, ?, tranquil-black
|
33
|
-
31, body brave-green, ?, brave-green
|
34
|
-
32, body crescent-green, ?, crescent-green
|
35
|
-
33, body emperor-green, ?, emperor-green
|
36
|
-
34, body guardian-green, ?, guardian-green
|
37
|
-
35, body crescent-pink, ?, crescent-pink
|
38
|
-
36, body guardian-pink, ?, guardian-pink
|
39
|
-
37, body sage-pink, ?, sage-pink
|
40
|
-
38, body stark-pink, ?, stark-pink
|
41
|
-
39, body tabby-pink, ?, tabby-pink
|
42
|
-
40, body tranquil-pink, ?, tranquil-pink
|
43
|
-
41, body brave-purple, ?, brave-purple
|
44
|
-
42, body sage-purple, ?, sage-purple
|
45
|
-
43, body stark-purple, ?, stark-purple
|
46
|
-
44, body tabby-purple, ?, tabby-purple
|
47
|
-
45, body tranquil-blue, ?, tranquil-blue
|
48
|
-
46, body crescent-blue, ?, crescent-blue
|
49
|
-
47, body professor-blue, ?, professor-blue
|
50
|
-
48, body stark-blue, ?, stark-blue
|
51
|
-
49, body crescent-golden, ?, crescent-golden
|
52
|
-
50, body emperor-golden, ?, emperor-golden
|
53
|
-
51, body professor-golden, ?, professor-golden
|
54
|
-
52, body sage-golden, ?, sage-golden
|
55
|
-
53, body ruby_skeleton, ?, ruby_skeleton
|
56
|
-
54, body skeleton, ?, skeleton
|
57
|
-
55, body robot, ?, robot
|
58
|
-
56, body brave-jade, ?, brave-jade
|
59
|
-
57, body crescent-jade, ?, crescent-jade
|
60
|
-
58, body brave-cosmic, ?, brave-cosmic
|
61
|
-
59, body crescent-cosmic, ?, crescent-cosmic
|
62
|
-
60, body brave-enlightened, ?, brave-enlightened
|
63
|
-
61, body crescent-enlightened, ?, crescent-enlightened
|
64
|
-
62, body brave-glitch, ?, brave-glitch
|
65
|
-
63, body guardian-glitch, ?, guardian-glitch
|
66
|
-
64, beak small-gray, ?, small-gray
|
67
|
-
65, beak small-orange, ?, small-orange
|
68
|
-
66, beak small-ruby, ?, small-ruby
|
69
|
-
67, beak small-skeleton, ?, small-skeleton
|
70
|
-
68, beak short-skeleton, ?, short-skeleton
|
71
|
-
69, beak long-skeleton, ?, long-skeleton
|
72
|
-
70, beak small-robot, ?, small-robot
|
73
|
-
71, beak short-robot, ?, short-robot
|
74
|
-
72, beak long-robot, ?, long-robot
|
75
|
-
73, beak small-golden, ?, small-golden
|
76
|
-
74, eyes open-blue, ?, open-blue
|
77
|
-
75, eyes open-green, ?, open-green
|
78
|
-
76, eyes open-purple, ?, open-purple
|
79
|
-
77, eyes open-red, ?, open-red
|
80
|
-
78, eyes open-white, ?, open-white
|
81
|
-
79, eyes adorable-skeleton, ?, adorable-skeleton
|
82
|
-
80, eyes angry-skeleton, ?, angry-skeleton
|
83
|
-
81, eyes open-skeleton, ?, open-skeleton
|
84
|
-
82, eyes relaxed-skeleton, ?, relaxed-skeleton
|
85
|
-
83, eyes angry-robot, ?, angry-robot
|
86
|
-
84, eyes open-robot, ?, open-robot
|
87
|
-
85, eyes angry-golden, ?, angry-golden
|
88
|
-
86, eyes open-golden, ?, open-golden
|
89
|
-
87, eyes side-eye-golden, ?, side-eye-golden
|
90
|
-
88, 3D Glasses, ?,
|
91
|
-
89, Black-Rimmed Glasses, ?,
|
92
|
-
90, eyepatch, ?,
|
93
|
-
91, gazelles, ?,
|
94
|
-
92, jobs_glasses, ?,
|
95
|
-
93, rose-colored_glasses, ?,
|
96
|
-
94, sunglasses, ?,
|
97
|
-
95, visor, ?,
|
98
|
-
96, aviators, ?,
|
99
|
-
97, chill, ?,
|
100
|
-
98, green_shades, ?,
|
101
|
-
99, neon_shades, ?,
|
102
|
-
100, rainbow_shades, ?,
|
103
|
-
101, red_shades, ?,
|
104
|
-
102, round_glasses, ?,
|
105
|
-
103, sunset_shades, ?,
|
106
|
-
104, vipers, ?,
|
107
|
-
105, Aviator's Cap, ?,
|
108
|
-
106, backwards_hat, ?,
|
109
|
-
107, bandana, ?,
|
110
|
-
108, beanie, ?,
|
111
|
-
109, bow, ?,
|
112
|
-
110, bucket_hat, ?,
|
113
|
-
111, Captain's Cap, ?,
|
114
|
-
112, Cowboy Hat 1, ?, Cowboy Hat
|
115
|
-
113, durag, ?,
|
116
|
-
114, flowers, ?,
|
117
|
-
115, forest_ranger, ?,
|
118
|
-
116, headband, ?,
|
119
|
-
117, headphones, ?,
|
120
|
-
118, Hero's Cap, ?,
|
121
|
-
119, karate_band, ?,
|
122
|
-
120, lincoln, ?,
|
123
|
-
121, Mohawk (Green), ?,
|
124
|
-
122, Mohawk (Pink), ?,
|
125
|
-
123, moon_hat, ?,
|
126
|
-
124, Pirate's Hat, ?,
|
127
|
-
125, Queen's Crown, ?,
|
128
|
-
126, tiara, ?,
|
129
|
-
127, Witch's Hat, ?,
|
130
|
-
128, Wizard's Hat, ?,
|
131
|
-
129, chromie, ?,
|
132
|
-
130, crescent_talisman, ?,
|
133
|
-
131, dancing_flame, ?,
|
134
|
-
132, fire, ?,
|
135
|
-
133, diamond, ?,
|
136
|
-
134, grail, ?,
|
137
|
-
135, gremplin, ?,
|
138
|
-
136, halo, ?,
|
139
|
-
137, raincloud, ?,
|
140
|
-
138, rubber_duck, ?,
|
141
|
-
139, skully, ?,
|
142
|
-
140, tiny_crown, ?,
|
143
|
-
141, Black Red Hat, ?,
|
144
|
-
142, Cowboy Hat 2, ?,
|
145
|
-
143, crown, ?,
|
146
|
-
144, gold, ?,
|
147
|
-
145, gray_hat, ?,
|
148
|
-
146, blue_bucket, ?,
|
149
|
-
147, red_bucket, ?,
|
150
|
-
148, White Bucket, ?,
|
151
|
-
149, star, ?,
|
152
|
-
150, McDonald's 1, ?, McDonald's
|
153
|
-
151, McDonald's 2, ?, McDonald's Visor
|
154
|
-
152, McDonald's 3, ?, McDonald's Red 1 | McDonald's Red
|
155
|
-
153, McDonald's 4, ?, McDonald's Red 2
|
156
|
-
154, McDonald's 5, ?, McDonald's Bucket Black
|
157
|
-
155, McDonald's 6, ?, McDonald's Black
|
158
|
-
156, McDonald's 7, ?, McDonald's White
|
159
|
-
157, Burger King 1, ?, Burger King
|
160
|
-
158, Burger King 2, ?,
|
161
|
-
159, Burger King Crown, ?,
|
162
|
-
160, KF1 1, ?, KFC
|
163
|
-
161, KFC 2, ?, KFC Family Bucket
|
164
|
-
162, Chick-Fil-A, ?,
|
165
|
-
163, Denny's, ?,
|
166
|
-
164, Domino's 1, ?, Domino's
|
167
|
-
165, Domino's 2, ?,
|
168
|
-
166, Dunkin' Donuts 1, ?, Dunkin' Donuts
|
169
|
-
167, Dunkin' Donuts 2, ?,
|
170
|
-
168, Hooters, ?,
|
171
|
-
169, In-N-Out 2, ?,
|
172
|
-
170, In-N-Out 1, ?, In-N-Out
|
173
|
-
171, wendys, ?,
|
174
|
-
172, white_castle, ?,
|
175
|
-
173, Pizza Hut 1, ?,
|
176
|
-
174, Pizza Hut 2, ?,
|
177
|
-
175, Subway 2, ?, Subway Visor
|
178
|
-
176, Subway 1, ?, Subway
|
179
|
-
177, Taco Bell, ?,
|
180
|
-
178, Walmart 1 Walmart, ?,
|
181
|
-
179, Walmart 2, ?,
|
182
|
-
180, Starbucks 1, ?, Starbucks
|
183
|
-
181, Starbucks 2, ?,
|
184
|
-
182, coffee_boy, ?,
|
185
|
-
183, Ben & Jerry's, ?,
|
186
|
-
184, chef-red, ?,
|
187
|
-
185, chef-white, ?,
|
188
|
-
186, grill_cook, ?,
|
189
|
-
187, drive-thru-on-duty, ?,
|
190
|
-
188, burger, ?,
|
191
|
-
189, fries, ?,
|
192
|
-
190, chicken, ?,
|
193
|
-
191, cola, ?,
|
194
|
-
192, popcorn, ?,
|
195
|
-
193, ice_cream_cone, ?,
|
196
|
-
194, taco, ?,
|
197
|
-
195, Hoodie, ?,
|
198
|
-
196, Hoodie Down, ?,
|
199
|
-
197, Punk Jacket, ?,
|
200
|
-
198, Blue Hoodie, ?,
|
201
|
-
199, Green Hoodie, ?,
|
202
|
-
200, Blue Shirt, ?,
|
203
|
-
201, Green Shirt, ?,
|
204
|
-
202, Orange Shirt, ?,
|
205
|
-
203, Red Shirt, ?,
|
206
|
-
204, tee, ?,
|
207
|
-
205, blue_scarf, ?,
|
208
|
-
206, green_scarf, ?,
|
209
|
-
207, red_scarf, ?,
|
210
|
-
208, el_pollo_loco_mascot, ?,
|
211
|
-
209, McDonald's Shirt, ?,
|
212
|
-
210, McDonald's Shirt (Classic), ?,
|
213
|
-
211, McDonald's Shirt (Old Skool), ?,
|
214
|
-
212, Manager Shirt, ?,
|
215
|
-
213, KFC Shirt, ?,
|
216
|
-
214, Starbucks Apron 1, ?, Starbucks Apron
|
217
|
-
215, Starbucks Apron 2, ?,
|
218
|
-
216, hibachi, ?,
|
data/config/spritesheet.png
DELETED
Binary file
|
data/lib/moonbirds/generator.rb
DELETED
@@ -1,190 +0,0 @@
|
|
1
|
-
|
2
|
-
module Moonbirds
|
3
|
-
|
4
|
-
class Metadata
|
5
|
-
class Sprite
|
6
|
-
attr_reader :id, :name, :type, :more_names
|
7
|
-
|
8
|
-
def initialize( id:,
|
9
|
-
name:,
|
10
|
-
type:,
|
11
|
-
more_names: [] )
|
12
|
-
@id = id # zero-based index eg. 0,1,2,3, etc.
|
13
|
-
@name = name
|
14
|
-
@type = type
|
15
|
-
@more_names = more_names
|
16
|
-
end
|
17
|
-
end # class Metadata::Sprite
|
18
|
-
end # class Metadata
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
class Generator
|
24
|
-
|
25
|
-
######
|
26
|
-
# static helpers - (turn into "true" static self.class methods - why? why not?)
|
27
|
-
#
|
28
|
-
def self.normalize_key( str )
|
29
|
-
## add & e.g. B&W
|
30
|
-
## add ' e.g. McDonald's Red
|
31
|
-
str.downcase.gsub(/[ ()&°'_-]/, '').strip
|
32
|
-
end
|
33
|
-
|
34
|
-
def self.normalize_name( str )
|
35
|
-
## normalize spaces in more names
|
36
|
-
str.strip.gsub( /[ ]{2,}/, ' ' )
|
37
|
-
end
|
38
|
-
|
39
|
-
def normalize_key( str ) self.class.normalize_key( str ); end
|
40
|
-
def normalize_name( str ) self.class.normalize_name( str ); end
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
def build_attributes_by_name( recs )
|
45
|
-
h = {}
|
46
|
-
recs.each_with_index do |rec|
|
47
|
-
names = [rec.name] + rec.more_names
|
48
|
-
|
49
|
-
names.each do |name|
|
50
|
-
key = normalize_key( name )
|
51
|
-
|
52
|
-
if h[ key ]
|
53
|
-
puts "!!! ERROR - attribute name is not unique:"
|
54
|
-
pp rec
|
55
|
-
puts "duplicate:"
|
56
|
-
pp h[key]
|
57
|
-
exit 1
|
58
|
-
end
|
59
|
-
h[ key ] = rec
|
60
|
-
end
|
61
|
-
end
|
62
|
-
## pp h
|
63
|
-
h
|
64
|
-
end
|
65
|
-
|
66
|
-
|
67
|
-
def build_recs( recs ) ## build and normalize (meta data) records
|
68
|
-
## sort by id
|
69
|
-
recs = recs.sort do |l,r|
|
70
|
-
l['id'].to_i( 10 ) <=> r['id'].to_i( 10 ) # use base10 (decimal)
|
71
|
-
end
|
72
|
-
|
73
|
-
## assert all recs are in order by id (0 to size)
|
74
|
-
recs.each_with_index do |rec, exp_id|
|
75
|
-
id = rec['id'].to_i(10)
|
76
|
-
if id != exp_id
|
77
|
-
puts "!! ERROR - meta data record ids out-of-order - expected id #{exp_id}; got #{id}"
|
78
|
-
exit 1
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
## convert to "wrapped / immutable" kind-of struct
|
83
|
-
recs = recs.map do |rec|
|
84
|
-
id = rec['id'].to_i( 10 )
|
85
|
-
name = normalize_name( rec['name'] )
|
86
|
-
type = rec['type']
|
87
|
-
|
88
|
-
more_names = (rec['more_names'] || '').split( '|' )
|
89
|
-
more_names = more_names.map {|str| normalize_name( str ) }
|
90
|
-
|
91
|
-
Metadata::Sprite.new(
|
92
|
-
id: id,
|
93
|
-
name: name,
|
94
|
-
type: type,
|
95
|
-
more_names: more_names )
|
96
|
-
end
|
97
|
-
recs
|
98
|
-
end # method build_recs
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
def initialize( image_path="./spritesheet.png",
|
103
|
-
meta_path="./spritesheet.csv" )
|
104
|
-
@sheet = Pixelart::ImageComposite.read( image_path, width: 42, height: 42 )
|
105
|
-
recs = CsvHash.read( meta_path )
|
106
|
-
|
107
|
-
@recs = build_recs( recs )
|
108
|
-
|
109
|
-
## lookup by "case/space-insensitive" name / key
|
110
|
-
@attributes_by_name = build_attributes_by_name( @recs )
|
111
|
-
end
|
112
|
-
|
113
|
-
|
114
|
-
def spritesheet() @sheet; end
|
115
|
-
alias_method :sheet, :spritesheet
|
116
|
-
|
117
|
-
|
118
|
-
def records() @recs; end
|
119
|
-
alias_method :meta, :records
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
def find_meta( q )
|
125
|
-
key = normalize_key( q ) ## normalize q(uery) string/symbol
|
126
|
-
|
127
|
-
rec = @attributes_by_name[ key ]
|
128
|
-
if rec
|
129
|
-
puts " lookup >#{key}< => #{rec.id}: #{rec.name} / #{rec.type}"
|
130
|
-
else
|
131
|
-
puts "!! WARN - no lookup found for key >#{key}<"
|
132
|
-
end
|
133
|
-
|
134
|
-
rec
|
135
|
-
end
|
136
|
-
|
137
|
-
def find( q )
|
138
|
-
rec = find_meta( q )
|
139
|
-
|
140
|
-
## return image if record found
|
141
|
-
rec ? @sheet[ rec.id ] : nil
|
142
|
-
end
|
143
|
-
|
144
|
-
|
145
|
-
def to_recs( *values )
|
146
|
-
recs = []
|
147
|
-
|
148
|
-
attribute_names = values
|
149
|
-
|
150
|
-
attribute_names.each do |attribute_name|
|
151
|
-
attribute = find_meta( attribute_name )
|
152
|
-
if attribute.nil?
|
153
|
-
puts "!! ERROR - attribute >#{attribute_name}< not found; sorry"
|
154
|
-
exit 1
|
155
|
-
end
|
156
|
-
recs << attribute
|
157
|
-
end
|
158
|
-
|
159
|
-
recs
|
160
|
-
end
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
def generate_image( *values, background: nil )
|
166
|
-
|
167
|
-
ids = if values[0].is_a?( Integer ) ## assume integer number (indexes)
|
168
|
-
values
|
169
|
-
else ## assume strings (names)
|
170
|
-
to_recs( *values ).map { |rec| rec.id }
|
171
|
-
end
|
172
|
-
|
173
|
-
|
174
|
-
img = Pixelart::Image.new( 42, 42 )
|
175
|
-
|
176
|
-
if background ## for now assume background is (simply) color
|
177
|
-
img.compose!( Pixelart::Image.new( 42, 42, background ) )
|
178
|
-
end
|
179
|
-
|
180
|
-
ids.each do |id|
|
181
|
-
img.compose!( @sheet[ id ] )
|
182
|
-
end
|
183
|
-
|
184
|
-
img
|
185
|
-
end
|
186
|
-
alias_method :generate, :generate_image
|
187
|
-
|
188
|
-
end # class Generator
|
189
|
-
|
190
|
-
end # module Moonbirds
|