moonbirds 0.1.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ac1faa3522772cfcd4fa687dbb7d7d916a7eac1adaf5308c8e4cf8b092a32b7
4
- data.tar.gz: c4b31f6268acd238e47da390e06d07bc0a3518719ed315f73d18650b922f600c
3
+ metadata.gz: 268df73eb3f233fd615d8f5cf299a1fbf53588fc899b847d7c24d863878d5fe8
4
+ data.tar.gz: '0983162928f19772dea75e0989d2b2b388b9fabfcdc132df53031ab361d222db'
5
5
  SHA512:
6
- metadata.gz: 66dcddda11a82cf0025c38fa7ec6eabb093d271c8b6ccb636b7987c0936f6632688868563f1bf21f4f872bb33fa0d2d2284fe2089a368eda2d758ea6f0015bd8
7
- data.tar.gz: 362a0cb553d09766ab7e014b667347deb8ea12ac7237754c63317a80b10972a2c9a7eda5f7a7615b561e2a98d8f1e9413f29e18a5c7410588e7da5b0e8940353
6
+ metadata.gz: 9b6c94f427063203960f9b5534515b082948ec9c9f54a3ca3a865ebf77b59ab7df6f9cd5bc11879918c7c28441c2de2ccbd264f23b6e6a4a9b00366ab75c9dfb
7
+ data.tar.gz: 489de2db5edf43c30859a0537165dcaeeabe2728fa5650e24253e58b533535680898fad4094fdfb9065dacf9d71bb1458839c8a9f6c46b70888576fe20584cdd
data/Manifest.txt CHANGED
@@ -5,5 +5,4 @@ Rakefile
5
5
  config/spritesheet.csv
6
6
  config/spritesheet.png
7
7
  lib/moonbirds.rb
8
- lib/moonbirds/generator.rb
9
8
  lib/moonbirds/version.rb
data/README.md CHANGED
@@ -63,19 +63,19 @@ bird.zoom( 4 ).save( "moonbird1e@4x.png" )
63
63
 
64
64
  Voila!
65
65
 
66
- ![](i/moonbird1.png)
67
- ![](i/moonbird1b.png)
68
- ![](i/moonbird1c.png)
69
- ![](i/moonbird1d.png)
70
- ![](i/moonbird1e.png)
66
+ ![](https://github.com/pixelartexchange/pixelart/raw/master/moonbirds/i/moonbird1.png)
67
+ ![](https://github.com/pixelartexchange/pixelart/raw/master/moonbirds/i/moonbird1b.png)
68
+ ![](https://github.com/pixelartexchange/pixelart/raw/master/moonbirds/i/moonbird1c.png)
69
+ ![](https://github.com/pixelartexchange/pixelart/raw/master/moonbirds/i/moonbird1d.png)
70
+ ![](https://github.com/pixelartexchange/pixelart/raw/master/moonbirds/i/moonbird1e.png)
71
71
 
72
72
  In 4x:
73
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)
74
+ ![](https://github.com/pixelartexchange/pixelart/raw/master/moonbirds/i/moonbird1@4x.png)
75
+ ![](https://github.com/pixelartexchange/pixelart/raw/master/moonbirds/i/moonbird1b@4x.png)
76
+ ![](https://github.com/pixelartexchange/pixelart/raw/master/moonbirds/i/moonbird1c@4x.png)
77
+ ![](https://github.com/pixelartexchange/pixelart/raw/master/moonbirds/i/moonbird1d@4x.png)
78
+ ![](https://github.com/pixelartexchange/pixelart/raw/master/moonbirds/i/moonbird1e@4x.png)
79
79
 
80
80
 
81
81
 
@@ -97,13 +97,13 @@ bird.zoom( 4 ).save( "moonbird2b@4x.png" )
97
97
 
98
98
  Voila!
99
99
 
100
- ![](i/moonbird2.png)
101
- ![](i/moonbird2b.png)
100
+ ![](https://github.com/pixelartexchange/pixelart/raw/master/moonbirds/i/moonbird2.png)
101
+ ![](https://github.com/pixelartexchange/pixelart/raw/master/moonbirds/i/moonbird2b.png)
102
102
 
103
103
  In 4x:
104
104
 
105
- ![](i/moonbird2@4x.png)
106
- ![](i/moonbird2b@4x.png)
105
+ ![](https://github.com/pixelartexchange/pixelart/raw/master/moonbirds/i/moonbird2@4x.png)
106
+ ![](https://github.com/pixelartexchange/pixelart/raw/master/moonbirds/i/moonbird2b@4x.png)
107
107
 
108
108
 
109
109
 
@@ -121,13 +121,13 @@ bird.zoom( 4 ).save( "moonbird3b@4x.png" )
121
121
 
122
122
  Voila!
123
123
 
124
- ![](i/moonbird3.png)
125
- ![](i/moonbird3b.png)
124
+ ![](https://github.com/pixelartexchange/pixelart/raw/master/moonbirds/i/moonbird3.png)
125
+ ![](https://github.com/pixelartexchange/pixelart/raw/master/moonbirds/i/moonbird3b.png)
126
126
 
127
127
  In 4x:
128
128
 
129
- ![](i/moonbird3@4x.png)
130
- ![](i/moonbird3b@4x.png)
129
+ ![](https://github.com/pixelartexchange/pixelart/raw/master/moonbirds/i/moonbird3@4x.png)
130
+ ![](https://github.com/pixelartexchange/pixelart/raw/master/moonbirds/i/moonbird3b@4x.png)
131
131
 
132
132
 
133
133
  And so on.
@@ -157,17 +157,17 @@ mcdonalds_red.zoom( 4 ).save( "mcdonalds_red@4x.png" )
157
157
 
158
158
  Voila!
159
159
 
160
- ![](i/3d_glasses.png)
161
- ![](i/beanie.png)
162
- ![](i/chromie.png)
163
- ![](i/mcdonalds_red.png)
160
+ ![](https://github.com/pixelartexchange/pixelart/raw/master/moonbirds/i/3d_glasses.png)
161
+ ![](https://github.com/pixelartexchange/pixelart/raw/master/moonbirds/i/beanie.png)
162
+ ![](https://github.com/pixelartexchange/pixelart/raw/master/moonbirds/i/chromie.png)
163
+ ![](https://github.com/pixelartexchange/pixelart/raw/master/moonbirds/i/mcdonalds_red.png)
164
164
 
165
165
  In 4x:
166
166
 
167
- ![](i/3d_glasses@4x.png)
168
- ![](i/beanie@4x.png)
169
- ![](i/chromie@4x.png)
170
- ![](i/mcdonalds_red@4x.png)
167
+ ![](https://github.com/pixelartexchange/pixelart/raw/master/moonbirds/i/3d_glasses@4x.png)
168
+ ![](https://github.com/pixelartexchange/pixelart/raw/master/moonbirds/i/beanie@4x.png)
169
+ ![](https://github.com/pixelartexchange/pixelart/raw/master/moonbirds/i/chromie@4x.png)
170
+ ![](https://github.com/pixelartexchange/pixelart/raw/master/moonbirds/i/mcdonalds_red@4x.png)
171
171
 
172
172
  And so on.
173
173
 
data/Rakefile CHANGED
@@ -26,8 +26,7 @@ Hoe.spec 'moonbirds' do
26
26
  self.history_file = 'CHANGELOG.md'
27
27
 
28
28
  self.extra_deps = [
29
- ['pixelart', '>= 1.3.0'],
30
- ['csvreader'],
29
+ ['pixelart', '>= 1.3.1'],
31
30
  ]
32
31
 
33
32
  self.licenses = ['Public Domain']
@@ -2,8 +2,8 @@
2
2
 
3
3
  module Moonbirds
4
4
 
5
- MAJOR = 0
6
- MINOR = 1
5
+ MAJOR = 1
6
+ MINOR = 0
7
7
  PATCH = 0
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
data/lib/moonbirds.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  ## 3rd party
2
2
  require 'pixelart/base'
3
- require 'csvreader'
4
3
 
5
4
 
6
5
 
@@ -13,7 +12,6 @@ module Moonbirds
13
12
  class Image < Pixelart::Image; end
14
13
  end
15
14
 
16
- require 'moonbirds/generator'
17
15
 
18
16
  ###
19
17
  ## add convenience pre-configurated generatored with build-in spritesheet (see config)
@@ -21,8 +19,10 @@ require 'moonbirds/generator'
21
19
  module Moonbirds
22
20
 
23
21
  def self.generator
24
- @generator ||= Generator.new( "#{root}/config/spritesheet.png",
25
- "#{root}/config/spritesheet.csv" )
22
+ @generator ||= Pixelart::Generator.new( "#{root}/config/spritesheet.png",
23
+ "#{root}/config/spritesheet.csv",
24
+ width: 42,
25
+ height: 42 )
26
26
  end
27
27
 
28
28
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moonbirds
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-18 00:00:00.000000000 Z
11
+ date: 2022-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pixelart
@@ -16,28 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.3.0
19
+ version: 1.3.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
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'
26
+ version: 1.3.1
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: rdoc
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -90,7 +76,6 @@ files:
90
76
  - config/spritesheet.csv
91
77
  - config/spritesheet.png
92
78
  - lib/moonbirds.rb
93
- - lib/moonbirds/generator.rb
94
79
  - lib/moonbirds/version.rb
95
80
  homepage: https://github.com/pixelartexchange/pixelart
96
81
  licenses:
@@ -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