moonbirds 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +3 -0
- data/Manifest.txt +9 -0
- data/README.md +179 -0
- data/Rakefile +39 -0
- data/config/spritesheet.csv +218 -0
- data/config/spritesheet.png +0 -0
- data/lib/moonbirds/generator.rb +190 -0
- data/lib/moonbirds/version.rb +23 -0
- data/lib/moonbirds.rb +69 -0
- metadata +122 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1ac1faa3522772cfcd4fa687dbb7d7d916a7eac1adaf5308c8e4cf8b092a32b7
|
4
|
+
data.tar.gz: c4b31f6268acd238e47da390e06d07bc0a3518719ed315f73d18650b922f600c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 66dcddda11a82cf0025c38fa7ec6eabb093d271c8b6ccb636b7987c0936f6632688868563f1bf21f4f872bb33fa0d2d2284fe2089a368eda2d758ea6f0015bd8
|
7
|
+
data.tar.gz: 362a0cb553d09766ab7e014b667347deb8ea12ac7237754c63317a80b10972a2c9a7eda5f7a7615b561e2a98d8f1e9413f29e18a5c7410588e7da5b0e8940353
|
data/CHANGELOG.md
ADDED
data/Manifest.txt
ADDED
data/README.md
ADDED
@@ -0,0 +1,179 @@
|
|
1
|
+
# Moonbirds (Pixel Owls 'n' Friends)
|
2
|
+
|
3
|
+
moonbirds - generate your own 42×42 pixel owl images (off chain) from text attributes (via built-in spritesheet); incl. 2x/4x/8x zoom for bigger sizes and more
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
* home :: [github.com/pixelartexchange/pixelart](https://github.com/pixelartexchange/pixelart)
|
8
|
+
* bugs :: [github.com/pixelartexchange/pixelart/issues](https://github.com/pixelartexchange/pixelart/issues)
|
9
|
+
* gem :: [rubygems.org/gems/moonbirds](https://rubygems.org/gems/moonbirds)
|
10
|
+
* rdoc :: [rubydoc.info/gems/moonbirds](http://rubydoc.info/gems/moonbirds)
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
Let's generate some super-rare never-before-seen
|
18
|
+
moonbirds (pixel owls):
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
require 'moonbirds'
|
22
|
+
|
23
|
+
########
|
24
|
+
# Moonbird No. 1
|
25
|
+
bird = Moonbird::Image.generate( "Tabby Brown",
|
26
|
+
"Beak Small Orange",
|
27
|
+
"Eyes Open White" )
|
28
|
+
bird.save( "moonbird1.png" )
|
29
|
+
bird.zoom( 4 ).save( "moonbird1@4x.png" )
|
30
|
+
|
31
|
+
# let's add 3D Glasses
|
32
|
+
bird = Moonbird::Image.generate( "Tabby Brown",
|
33
|
+
"Beak Small Orange",
|
34
|
+
"Eyes Open White",
|
35
|
+
"3D Glasses" )
|
36
|
+
bird.save( "moonbird1b.png" )
|
37
|
+
bird.zoom( 4 ).save( "moonbird1b@4x.png" )
|
38
|
+
|
39
|
+
# let's add McDonald's Red (from the Fast Food Series)
|
40
|
+
bird = Moonbird::Image.generate( "Tabby Brown",
|
41
|
+
"Beak Small Orange",
|
42
|
+
"Eyes Open White",
|
43
|
+
"McDonald's Red" )
|
44
|
+
bird.zoom( 4 ).save( "moonbird1c@4x.png" )
|
45
|
+
|
46
|
+
# let's add Drive-Thru On Duty (from the Fast Food Series)
|
47
|
+
bird = Moonbird::Image.generate( "Tabby Brown",
|
48
|
+
"Beak Small Orange",
|
49
|
+
"Eyes Open White",
|
50
|
+
"McDonald's Red",
|
51
|
+
"Drive-Thru On Duty" )
|
52
|
+
bird.zoom( 4 ).save( "moonbird1d@4x.png" )
|
53
|
+
|
54
|
+
# let's add McDonald's Shirt - Old Skool (from the Fast Food Series)
|
55
|
+
bird = Moonbird::Image.generate( "Tabby Brown",
|
56
|
+
"Beak Small Orange",
|
57
|
+
"Eyes Open White",
|
58
|
+
"McDonald's Red",
|
59
|
+
"Drive-Thru On Duty",
|
60
|
+
"McDonald's Shirt (Old Skool)" )
|
61
|
+
bird.zoom( 4 ).save( "moonbird1e@4x.png" )
|
62
|
+
```
|
63
|
+
|
64
|
+
Voila!
|
65
|
+
|
66
|
+
![](i/moonbird1.png)
|
67
|
+
![](i/moonbird1b.png)
|
68
|
+
![](i/moonbird1c.png)
|
69
|
+
![](i/moonbird1d.png)
|
70
|
+
![](i/moonbird1e.png)
|
71
|
+
|
72
|
+
In 4x:
|
73
|
+
|
74
|
+
![](i/moonbird1@4x.png)
|
75
|
+
![](i/moonbird1b@4x.png)
|
76
|
+
![](i/moonbird1c@4x.png)
|
77
|
+
![](i/moonbird1d@4x.png)
|
78
|
+
![](i/moonbird1e@4x.png)
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
###
|
84
|
+
# Moonbird No. 2
|
85
|
+
bird = Moonbird::Image.generate( "Professor Golden",
|
86
|
+
"Beak Small Golden",
|
87
|
+
"Eyes Open Golden" )
|
88
|
+
bird.zoom( 4 ).save( "moonbird2@4x.png" )
|
89
|
+
|
90
|
+
# let's add Beanie
|
91
|
+
bird = Moonbird::Image.generate( "Crescent Golden",
|
92
|
+
"Beak Small Golden",
|
93
|
+
"Eyes Open Golden",
|
94
|
+
"Beanie" )
|
95
|
+
bird.zoom( 4 ).save( "moonbird2b@4x.png" )
|
96
|
+
```
|
97
|
+
|
98
|
+
Voila!
|
99
|
+
|
100
|
+
![](i/moonbird2.png)
|
101
|
+
![](i/moonbird2b.png)
|
102
|
+
|
103
|
+
In 4x:
|
104
|
+
|
105
|
+
![](i/moonbird2@4x.png)
|
106
|
+
![](i/moonbird2b@4x.png)
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
```ruby
|
111
|
+
###
|
112
|
+
# Moonbird No. 3
|
113
|
+
bird = Moonbird::Image.generate( "Brave Glitch" )
|
114
|
+
bird.zoom( 4 ).save( "moonbird3@4x.png" )
|
115
|
+
|
116
|
+
# let's add a red background
|
117
|
+
bird = Moonbird::Image.generate( "Brave Glitch", background: 'red' )
|
118
|
+
bird.zoom( 4 ).save( "moonbird3b@4x.png" )
|
119
|
+
|
120
|
+
```
|
121
|
+
|
122
|
+
Voila!
|
123
|
+
|
124
|
+
![](i/moonbird3.png)
|
125
|
+
![](i/moonbird3b.png)
|
126
|
+
|
127
|
+
In 4x:
|
128
|
+
|
129
|
+
![](i/moonbird3@4x.png)
|
130
|
+
![](i/moonbird3b@4x.png)
|
131
|
+
|
132
|
+
|
133
|
+
And so on.
|
134
|
+
|
135
|
+
### Bonus - Look-Up Attributes (Via Built-In Spritesheet)
|
136
|
+
|
137
|
+
|
138
|
+
Let's look-up some attributes:
|
139
|
+
|
140
|
+
```ruby
|
141
|
+
_3d_glasses = Moonbird::Sheet.find_by( name: '3D Glasses' )
|
142
|
+
beanie = Moonbird::Sheet.find_by( name: 'Beanie' )
|
143
|
+
chromie = Moonbird::Sheet.find_by( name: 'Chromie' )
|
144
|
+
|
145
|
+
mcdonalds_red = Moonbird::Sheet.find_by( name: "McDonald's Red" )
|
146
|
+
|
147
|
+
_3d_glasses.save( "3d_glasses.png" )
|
148
|
+
beanie.save( "beanie.png" )
|
149
|
+
chromie.save( "chromie.png" )
|
150
|
+
mcdonalds_red.save( "mcdonalds_red.png" )
|
151
|
+
|
152
|
+
_3d_glasses.zoom( 4 ).save( "3d_glasses@4x.png" )
|
153
|
+
beanie.zoom( 4 ).save( "beanie@4x.png" )
|
154
|
+
chromie.zoom( 4 ).save( "chromie@4x.png" )
|
155
|
+
mcdonalds_red.zoom( 4 ).save( "mcdonalds_red@4x.png" )
|
156
|
+
```
|
157
|
+
|
158
|
+
Voila!
|
159
|
+
|
160
|
+
![](i/3d_glasses.png)
|
161
|
+
![](i/beanie.png)
|
162
|
+
![](i/chromie.png)
|
163
|
+
![](i/mcdonalds_red.png)
|
164
|
+
|
165
|
+
In 4x:
|
166
|
+
|
167
|
+
![](i/3d_glasses@4x.png)
|
168
|
+
![](i/beanie@4x.png)
|
169
|
+
![](i/chromie@4x.png)
|
170
|
+
![](i/mcdonalds_red@4x.png)
|
171
|
+
|
172
|
+
And so on.
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
## Questions? Comments?
|
178
|
+
|
179
|
+
Post them on the [CryptoPunksDev reddit](https://old.reddit.com/r/CryptoPunksDev). Thanks.
|
data/Rakefile
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'hoe'
|
2
|
+
require './lib/moonbirds/version.rb'
|
3
|
+
|
4
|
+
###
|
5
|
+
# hack/ quick fix for broken intuit_values - overwrite with dummy
|
6
|
+
class Hoe
|
7
|
+
def intuit_values( input ); end
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
Hoe.spec 'moonbirds' do
|
13
|
+
|
14
|
+
self.version = Moonbirds::VERSION
|
15
|
+
|
16
|
+
self.summary = "moonbirds - generate your own 42×42 pixel owl images (off chain) from text attributes (via built-in spritesheet); incl. 2x/4x/8x zoom for bigger sizes and more"
|
17
|
+
self.description = summary
|
18
|
+
|
19
|
+
self.urls = { home: 'https://github.com/pixelartexchange/pixelart' }
|
20
|
+
|
21
|
+
self.author = 'Gerald Bauer'
|
22
|
+
self.email = 'wwwmake@googlegroups.com'
|
23
|
+
|
24
|
+
# switch extension to .markdown for gihub formatting
|
25
|
+
self.readme_file = 'README.md'
|
26
|
+
self.history_file = 'CHANGELOG.md'
|
27
|
+
|
28
|
+
self.extra_deps = [
|
29
|
+
['pixelart', '>= 1.3.0'],
|
30
|
+
['csvreader'],
|
31
|
+
]
|
32
|
+
|
33
|
+
self.licenses = ['Public Domain']
|
34
|
+
|
35
|
+
self.spec_extras = {
|
36
|
+
required_ruby_version: '>= 2.3'
|
37
|
+
}
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,218 @@
|
|
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, ?,
|
Binary file
|
@@ -0,0 +1,190 @@
|
|
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
|
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module Moonbirds
|
4
|
+
|
5
|
+
MAJOR = 0
|
6
|
+
MINOR = 1
|
7
|
+
PATCH = 0
|
8
|
+
VERSION = [MAJOR,MINOR,PATCH].join('.')
|
9
|
+
|
10
|
+
def self.version
|
11
|
+
VERSION
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.banner
|
15
|
+
"moonbirds/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] in (#{root})"
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.root
|
19
|
+
File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
|
20
|
+
end
|
21
|
+
|
22
|
+
end # module Moonbirds
|
23
|
+
|
data/lib/moonbirds.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
## 3rd party
|
2
|
+
require 'pixelart/base'
|
3
|
+
require 'csvreader'
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
## our own code
|
8
|
+
require 'moonbirds/version' # note: let version always go first
|
9
|
+
|
10
|
+
|
11
|
+
## forward define superclass for image
|
12
|
+
module Moonbirds
|
13
|
+
class Image < Pixelart::Image; end
|
14
|
+
end
|
15
|
+
|
16
|
+
require 'moonbirds/generator'
|
17
|
+
|
18
|
+
###
|
19
|
+
## add convenience pre-configurated generatored with build-in spritesheet (see config)
|
20
|
+
|
21
|
+
module Moonbirds
|
22
|
+
|
23
|
+
def self.generator
|
24
|
+
@generator ||= Generator.new( "#{root}/config/spritesheet.png",
|
25
|
+
"#{root}/config/spritesheet.csv" )
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
class Image
|
30
|
+
def self.generate( *values, background: nil )
|
31
|
+
img = Moonbirds.generator.generate( *values, background: background )
|
32
|
+
## note: unwrap inner image before passing on to c'tor (requires ChunkyPNG image for now)
|
33
|
+
new( 42, 42, img.image )
|
34
|
+
end # method Image.generate
|
35
|
+
end # class Image
|
36
|
+
|
37
|
+
|
38
|
+
class Spritesheet
|
39
|
+
## note: for now class used for "namespace" only
|
40
|
+
def self.find_by( name: ) ## return archetype/attribute image by name
|
41
|
+
# note: pass along name as q (query string)
|
42
|
+
Moonbirds.generator.find( name )
|
43
|
+
end
|
44
|
+
end # class Spritesheet
|
45
|
+
## add convenience (alternate spelling) alias - why? why not?
|
46
|
+
SpriteSheet = Spritesheet
|
47
|
+
Sheet = Spritesheet
|
48
|
+
Sprite = Spritesheet
|
49
|
+
end # module Moonbirds
|
50
|
+
|
51
|
+
|
52
|
+
### add some convenience shortcuts
|
53
|
+
MoonBirds = Moonbirds
|
54
|
+
Birds = Moonbirds
|
55
|
+
## add singular too -why? why not?
|
56
|
+
Moonbird = Moonbirds
|
57
|
+
MoonBird = Moonbirds
|
58
|
+
Bird = Moonbirds
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
###
|
64
|
+
# note: for convenience auto include Pixelart namespace!!! - why? why not?
|
65
|
+
include Pixelart
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
puts Moonbirds.banner # say hello
|
metadata
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: moonbirds
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gerald Bauer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-05-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: pixelart
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.3.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.3.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: csvreader
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rdoc
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4.0'
|
48
|
+
- - "<"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '7'
|
51
|
+
type: :development
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '4.0'
|
58
|
+
- - "<"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '7'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: hoe
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '3.23'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '3.23'
|
75
|
+
description: moonbirds - generate your own 42×42 pixel owl images (off chain) from
|
76
|
+
text attributes (via built-in spritesheet); incl. 2x/4x/8x zoom for bigger sizes
|
77
|
+
and more
|
78
|
+
email: wwwmake@googlegroups.com
|
79
|
+
executables: []
|
80
|
+
extensions: []
|
81
|
+
extra_rdoc_files:
|
82
|
+
- CHANGELOG.md
|
83
|
+
- Manifest.txt
|
84
|
+
- README.md
|
85
|
+
files:
|
86
|
+
- CHANGELOG.md
|
87
|
+
- Manifest.txt
|
88
|
+
- README.md
|
89
|
+
- Rakefile
|
90
|
+
- config/spritesheet.csv
|
91
|
+
- config/spritesheet.png
|
92
|
+
- lib/moonbirds.rb
|
93
|
+
- lib/moonbirds/generator.rb
|
94
|
+
- lib/moonbirds/version.rb
|
95
|
+
homepage: https://github.com/pixelartexchange/pixelart
|
96
|
+
licenses:
|
97
|
+
- Public Domain
|
98
|
+
metadata: {}
|
99
|
+
post_install_message:
|
100
|
+
rdoc_options:
|
101
|
+
- "--main"
|
102
|
+
- README.md
|
103
|
+
require_paths:
|
104
|
+
- lib
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '2.3'
|
110
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
requirements: []
|
116
|
+
rubygems_version: 3.3.7
|
117
|
+
signing_key:
|
118
|
+
specification_version: 4
|
119
|
+
summary: moonbirds - generate your own 42×42 pixel owl images (off chain) from text
|
120
|
+
attributes (via built-in spritesheet); incl. 2x/4x/8x zoom for bigger sizes and
|
121
|
+
more
|
122
|
+
test_files: []
|