punks 0.2.0 → 0.2.1

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: 6c593415e2ffb205d53b0f37c2c39e0248e9bd603727556d19488372512777b6
4
- data.tar.gz: e1ea7e9bb6c4d94c2d674d7107b69059f80d5badc97e2cdea2dc69f7d46e5a5e
3
+ metadata.gz: f0c521c2cbcf4604bebb732f0f09b741a1b535545048995451e04a5326c6a01e
4
+ data.tar.gz: 4caa12cae6db2396a83d5fdf2b207ed34b9ed9cd2d76ad6e73755bd98219e608
5
5
  SHA512:
6
- metadata.gz: 4bacfe06d637934b1791287a760ed9e2d17985280ed0af491d6619796c1ae3744f4c12bee3c00b2a6b72d13015bdcd87906e672a1c31f5c0f8b31d5bc19d47af
7
- data.tar.gz: 6c9680f7f1e9aeca3913e5d471293f78ee0ca472d7961e267e60cafa8092674f1f349dcd9e63fc48dc4a2e0749153ef41ba498ffe1a5ea53b1da9d8aece59079
6
+ metadata.gz: 9b753d3425775ed6e5dc69de0b6ca52bc59a1ccb3946ee7a0699ead8e4a03e552d89d21d931bd0f89ed0842df9ad9cf12ed47aec74d6cab3dfce916e72c2384c
7
+ data.tar.gz: f8e8cb86553017fdb43638fdeb2b248f6169635ecfc33eace2577bf42f4d515d13e79a1b9a9ea07b8393bc4b077cd79ffa3593dc4da2876676dec679d8c36a06
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  The Do-It-Yourself (DIY) [Factory of Modern Originals (FoMO)](https://github.com/pixelartexchange/originals) Presents
2
2
 
3
- # Punks (Pixel Characters / Avatars)
3
+ # Punks, Phunks, Philips, Marilyns & More (Pixel Characters / Avatars)
4
4
 
5
- Yes, you can! Generate your own 24×24 or 32×32 punk (pixel) avatar / character images (off chain) from text attributes (via built-in spritesheet); incl. 2x/4x/8x zoom for bigger sizes and more
5
+ Yes, you can! Generate your own 24×24 (or 32×32) punk, phunk, philip, marilyn & more (pixel) avatar / character images (off chain) from text attributes (via built-in spritesheet); incl. 2x/4x/8x zoom for bigger sizes and more
6
6
 
7
7
 
8
8
 
data/Rakefile CHANGED
@@ -13,7 +13,7 @@ Hoe.spec 'punks' do
13
13
 
14
14
  self.version = Pixelart::Module::Punks::VERSION
15
15
 
16
- self.summary = "punks - generate your own 24×24 or 32×32 punk (pixel) avatar / character images (off chain) from text attributes (via built-in spritesheet); incl. 2x/4x/8x zoom for bigger sizes and more"
16
+ self.summary = "punks - generate your own 24×24 (or 32×32) punk, phunk, philip, marilyn 'n' more (pixel) avatar / character images (off chain) from text attributes (via built-in spritesheet); incl. 2x/4x/8x zoom for bigger sizes and more"
17
17
  self.description = summary
18
18
 
19
19
  self.urls = { home: 'https://github.com/cryptopunksnotdead/cryptopunks' }
@@ -169,8 +169,6 @@ module Punk
169
169
  alias_method :meta, :records
170
170
 
171
171
 
172
-
173
-
174
172
  def find_meta( q, gender: nil,
175
173
  size: nil,
176
174
  style: nil ) ## note: gender (m/f) required for attributes!!!
@@ -247,34 +245,55 @@ module Punk
247
245
 
248
246
 
249
247
 
250
- def to_recs( *values, style: nil )
248
+ def to_recs( *values, style: nil, patch: nil )
251
249
  archetype_name = values[0]
252
250
 
253
- ### todo/fix: check for nil/not found!!!!
254
- ## todo/check/fix: assert meta record returned is archetype NOT attribute!!!!
255
- archetype = find_meta( archetype_name )
256
- if archetype.nil?
257
- puts "!! ERROR - archetype >#{archetype}< not found; sorry"
258
- exit 1
251
+ if archetype_name.is_a?( Pixelart::Image )
252
+ archetype = archetype_name
253
+ elsif patch && img=patch[ normalize_key(archetype_name) ]
254
+ archetype = img
255
+ else ## assume it's a string
256
+ ### todo/fix: check for nil/not found!!!!
257
+ ## todo/check/fix: assert meta record returned is archetype NOT attribute!!!!
258
+ archetype = find_meta( archetype_name )
259
+ if archetype.nil?
260
+ puts "!! ERROR - archetype >#{archetype}< not found; sorry"
261
+ exit 1
262
+ end
259
263
  end
260
264
 
261
265
  recs = [archetype]
262
266
 
263
- attribute_names = values[1..-1]
264
267
  ## note: attribute lookup requires gender from archetype!!!!
265
- attribute_gender = archetype.gender
266
- attribute_size = archetype.size
268
+ if archetype.is_a?( Pixelart::Image )
269
+ ### for now assume (support only)
270
+ ## large & unisex (u&u) for "inline/patch" archetypes - why? why not?
271
+ attribute_gender = 'u'
272
+ attribute_size = 'l'
273
+ else
274
+ attribute_gender = archetype.gender
275
+ attribute_size = archetype.size
276
+ end
267
277
 
278
+ attribute_names = values[1..-1]
268
279
  attribute_names.each do |attribute_name|
269
- attribute = find_meta( attribute_name,
270
- gender: attribute_gender,
271
- size: attribute_size,
272
- style: style )
273
- if attribute.nil?
274
- puts "!! ERROR - attribute >#{attribute_name}< for (#{attribute_gender}+#{attribute_size}) not found; sorry"
275
- exit 1
276
- end
277
- recs << attribute
280
+ ## note: quick hack - allow "inline" raw images for now - why? why not?
281
+ ## pass through as-is
282
+ if attribute_name.is_a?( Pixelart::Image )
283
+ recs << attribute_name
284
+ elsif patch && img=patch[ normalize_key(attribute_name) ]
285
+ recs << img
286
+ else
287
+ rec = find_meta( attribute_name,
288
+ gender: attribute_gender,
289
+ size: attribute_size,
290
+ style: style )
291
+ if rec.nil?
292
+ puts "!! ERROR - attribute >#{attribute_name}< for (#{attribute_gender}+#{attribute_size}) not found; sorry"
293
+ exit 1
294
+ end
295
+ recs << rec
296
+ end
278
297
  end
279
298
 
280
299
  recs
@@ -283,14 +302,22 @@ module Punk
283
302
 
284
303
 
285
304
 
286
- def generate_image( *values, style: nil )
305
+ def generate_image( *values, style: nil, patch: nil )
306
+ ## check: rename patch to more/extras/foreign or ... - why? why not?
287
307
 
288
- recs = to_recs( *values, style: style )
308
+ recs = to_recs( *values, style: style, patch: patch )
289
309
 
290
310
  punk = @image_class.new( 24, 24 )
291
311
 
292
312
  recs.each do |rec|
293
- punk.compose!( @sheet[ rec.id ] )
313
+ ## note: quick hack - allow "inline" raw images for now - why? why not?
314
+ ## pass through as-is
315
+ img = if rec.is_a?( Pixelart::Image )
316
+ rec
317
+ else
318
+ @sheet[ rec.id ]
319
+ end
320
+ punk.compose!( img )
294
321
  end
295
322
 
296
323
  punk
data/lib/punks/punks.rb CHANGED
@@ -10,46 +10,48 @@ module Punk
10
10
  end
11
11
 
12
12
 
13
- def self.generate( *values, style: nil )
14
-
15
- ##### add style option / hack - why? why not?
16
- if style
17
- values = if style.downcase.index( 'natural') && style.downcase.index( '2')
18
- ["#{values[0]} (N2)"] + values[1..-1]
19
- elsif style.downcase[0] == 'n' ## starting with n - always assume natural(s)
20
- ## auto-add (N) for Natural to archetype
21
- ["#{values[0]} (N)"] + values[1..-1]
22
- else
23
- puts "!! ERROR - unknown punk style #{style}; sorry"
24
- exit 1
25
- end
26
- end
27
-
28
-
29
- ###### hack for black&white
30
- ## auto-add b&w (black&white) to all attribute names e.g.
31
- ## Eyes => Eyes B&W
32
- ## Smile => Smile B&W
33
- ## ....
34
-
35
- archetype_key = Generator.normalize_key( values[0] )
36
- if archetype_key.end_with?( 'bw' ) || ## e.g. B&W
37
- archetype_key.end_with?( '1bit') ## e.g. 1-Bit or 1Bit
38
-
39
- values = [values[0]] + values[1..-1].map do |attribute|
40
- attribute_key = Generator.normalize_key( attribute )
41
- if ['wildhair'].include?( attribute_key ) ## pass through known b&w attributes by "default"
42
- attribute
43
- elsif attribute_key.index( "black" )
44
- attribute ## pass through as-is
45
- else
46
- "#{attribute} B&W"
47
- end
13
+ def self.generate( *values, style: nil, patch: nil )
14
+
15
+ if values[0].is_a?( String )
16
+ ##### add style option / hack - why? why not?
17
+ if style
18
+ values = if style.downcase.index( 'natural') && style.downcase.index( '2')
19
+ ["#{values[0]} (N2)"] + values[1..-1]
20
+ elsif style.downcase[0] == 'n' ## starting with n - always assume natural(s)
21
+ ## auto-add (N) for Natural to archetype
22
+ ["#{values[0]} (N)"] + values[1..-1]
23
+ else
24
+ puts "!! ERROR - unknown punk style #{style}; sorry"
25
+ exit 1
26
+ end
48
27
  end
49
28
 
50
- pp values
51
- end
52
-
29
+ ###### hack for black&white
30
+ ## auto-add b&w (black&white) to all attribute names e.g.
31
+ ## Eyes => Eyes B&W
32
+ ## Smile => Smile B&W
33
+ ## ....
34
+ archetype_key = Generator.normalize_key( values[0] )
35
+ if archetype_key.end_with?( 'bw' ) || ## e.g. B&W
36
+ archetype_key.end_with?( '1bit') ## e.g. 1-Bit or 1Bit
37
+
38
+ values = [values[0]] + values[1..-1].map do |attribute|
39
+ if attribute.is_a?( Pixelart::Image )
40
+ attribute
41
+ else
42
+ attribute_key = Generator.normalize_key( attribute )
43
+ if ['wildhair'].include?( attribute_key ) ## pass through known b&w attributes by "default"
44
+ attribute
45
+ elsif attribute_key.index( "black" )
46
+ attribute ## pass through as-is
47
+ else
48
+ "#{attribute} B&W"
49
+ end
50
+ end
51
+ end
52
+
53
+ pp values
54
+ end
53
55
 
54
56
  # note: female mouth by default has "custom" colors (not black)
55
57
  # for every 1/2/3/4 (human) skin tone and for zombie
@@ -68,25 +70,30 @@ module Punk
68
70
  archetype_key.index( 'zombiefemale' )
69
71
 
70
72
  values = [values[0]] + values[1..-1].map do |attribute|
71
- attribute_key = Generator.normalize_key( attribute )
72
-
73
- if attribute_key == 'smile' || attribute_key == 'frown'
74
- attribute += if archetype_key.index( 'zombiefemale' ) then ' Zombie'
75
- elsif archetype_key.index( 'female1' ) then ' 1'
76
- elsif archetype_key.index( 'female2' ) then ' 2'
77
- elsif archetype_key.index( 'female3' ) then ' 3'
78
- elsif archetype_key.index( 'female4' ) then ' 4'
79
- else
80
- puts "!! ERROR - smile or frown (mouth expression) not supported for archetype:"
81
- pp values
82
- exit 1
83
- end
73
+ if attribute.is_a?( Pixelart::Image )
74
+ attribute
75
+ else
76
+ attribute_key = Generator.normalize_key( attribute )
77
+
78
+ if attribute_key == 'smile' || attribute_key == 'frown'
79
+ attribute += if archetype_key.index( 'zombiefemale' ) then ' Zombie'
80
+ elsif archetype_key.index( 'female1' ) then ' 1'
81
+ elsif archetype_key.index( 'female2' ) then ' 2'
82
+ elsif archetype_key.index( 'female3' ) then ' 3'
83
+ elsif archetype_key.index( 'female4' ) then ' 4'
84
+ else
85
+ puts "!! ERROR - smile or frown (mouth expression) not supported for archetype:"
86
+ pp values
87
+ exit 1
88
+ end
89
+ end
90
+ attribute
84
91
  end
85
- attribute
86
92
  end
87
93
  end
94
+ end
88
95
 
89
- generator.generate( *values, style: style )
96
+ generator.generate( *values, style: style, patch: patch )
90
97
  end # method Image.generate
91
98
  end # class Image
92
99
 
data/lib/punks/version.rb CHANGED
@@ -5,7 +5,7 @@ module Punks
5
5
 
6
6
  MAJOR = 0
7
7
  MINOR = 2
8
- PATCH = 0
8
+ PATCH = 1
9
9
  VERSION = [MAJOR,MINOR,PATCH].join('.')
10
10
 
11
11
  def self.version
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: punks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
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-06-11 00:00:00.000000000 Z
11
+ date: 2022-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pixelart
@@ -86,9 +86,9 @@ dependencies:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
88
  version: '3.23'
89
- description: punks - generate your own 24×24 or 32×32 punk (pixel) avatar / character
90
- images (off chain) from text attributes (via built-in spritesheet); incl. 2x/4x/8x
91
- zoom for bigger sizes and more
89
+ description: punks - generate your own 24×24 (or 32×32) punk, phunk, philip, marilyn
90
+ 'n' more (pixel) avatar / character images (off chain) from text attributes (via
91
+ built-in spritesheet); incl. 2x/4x/8x zoom for bigger sizes and more
92
92
  email: wwwmake@googlegroups.com
93
93
  executables: []
94
94
  extensions: []
@@ -138,7 +138,7 @@ requirements: []
138
138
  rubygems_version: 3.3.7
139
139
  signing_key:
140
140
  specification_version: 4
141
- summary: punks - generate your own 24×24 or 32×32 punk (pixel) avatar / character
142
- images (off chain) from text attributes (via built-in spritesheet); incl. 2x/4x/8x
143
- zoom for bigger sizes and more
141
+ summary: punks - generate your own 24×24 (or 32×32) punk, phunk, philip, marilyn 'n'
142
+ more (pixel) avatar / character images (off chain) from text attributes (via built-in
143
+ spritesheet); incl. 2x/4x/8x zoom for bigger sizes and more
144
144
  test_files: []