punkmaker 0.0.1 → 0.2.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: 257366a7c0df4ae816f1eeebcf86951ebb46b544aa50ebe78dab967b3be81414
4
- data.tar.gz: f64bb2387a49c25d2d67aa81a25b68706d0cb0b8141be475fc5068d97b2b70b5
3
+ metadata.gz: f6692eb9ea8a32eb0d6f104039bba563dec993e5bebc83b771e18095e48b5f0d
4
+ data.tar.gz: 39ef67f256eba06343e750875e39627e73962cf159d2a81b3fee71c44edd041f
5
5
  SHA512:
6
- metadata.gz: 03653d15ea50dabca8a519eca28f5c8c160e004f8db0a4faec4be7c8ad847137dcb9a168429304af25af9d95d02fabb0e555f11ec889c38a65ca9cf156bcb3df
7
- data.tar.gz: cd4f204ec6d777971764966b5df93e3c4fb9f6c0abe3e2cc1c888b7effc282b7ab8e575e15c5127fb416421de3d8e9392bf0960bcc4113cf5be43fd4cad6e7b3
6
+ metadata.gz: 10e1f2e5cb734d461c66586eea4b8312c7fdf1251ca03fe9b36b37851aadf308a03fd7322d05388f45041915ece2420da40b225e1f02afd6dff0410dcd7ee201
7
+ data.tar.gz: 5444664fa42726421e0ce510a69873249ac8d46b2c533dd7da118c429b49acdd1d8cc7a3b57873d660c51ad3ea6aacb12d9ae1eded5650435ff21d41f9b38ddd
data/CHANGELOG.md CHANGED
@@ -1,3 +1,4 @@
1
+ ### 0.2.0
1
2
  ### 0.0.1 / 2023-04-20
2
3
 
3
4
  * Everything is new. First release
data/Manifest.txt CHANGED
@@ -2,6 +2,12 @@ CHANGELOG.md
2
2
  Manifest.txt
3
3
  README.md
4
4
  Rakefile
5
+ config/human-female4.png
6
+ config/human-male4.png
7
+ config/mummy-female.png
8
+ config/mummy-male.png
5
9
  lib/punkmaker.rb
10
+ lib/punkmaker/hair.rb
6
11
  lib/punkmaker/human.rb
7
12
  lib/punkmaker/mummy.rb
13
+ lib/punkmaker/version.rb
data/README.md CHANGED
@@ -4,8 +4,8 @@ punkmaker gem - make your own (pixel) punk base (archetype) heads incl. humans,
4
4
 
5
5
 
6
6
 
7
- * home :: [github.com/cryptopunksnotdead/cryptopunks](https://github.com/cryptopunksnotdead/cryptopunks)
8
- * bugs :: [github.com/cryptopunksnotdead/cryptopunks/issues](https://github.com/cryptopunksnotdead/cryptopunks/issues)
7
+ * home :: [github.com/cryptopunksnotdead/punkart.sandbox](https://github.com/cryptopunksnotdead/punkart.sandbox)
8
+ * bugs :: [github.com/cryptopunksnotdead/punkart.sandbox/issues](https://github.com/cryptopunksnotdead/punkart.sandbox/issues)
9
9
  * gem :: [rubygems.org/gems/punkmaker](https://rubygems.org/gems/punkmaker)
10
10
  * rdoc :: [rubydoc.info/gems/punkmaker](http://rubydoc.info/gems/punkmaker)
11
11
 
@@ -69,6 +69,9 @@ Use it as you please with no restrictions whatsoever.
69
69
 
70
70
  ## Questions? Comments?
71
71
 
72
- Post them over at the [Help & Support](https://github.com/geraldb/help) page. Thanks.
72
+ Join us in the [Punk Art discord (chat server)](https://discord.gg/FE3HeXNKRa). Yes you can.
73
+ Your questions and commentary welcome.
74
+
75
+ Or post them over at the [Help & Support](https://github.com/geraldb/help) page. Thanks.
73
76
 
74
77
 
data/Rakefile CHANGED
@@ -1,21 +1,22 @@
1
1
  require 'hoe'
2
+ require './lib/punkmaker/version.rb'
2
3
 
3
4
 
4
5
  ###
5
6
  # hack/ quick fix for broken intuit_values - overwrite with dummy
6
- class Hoe
7
- def intuit_values( input ); end
8
- end
7
+ # class Hoe
8
+ # def intuit_values( input ); end
9
+ # end
9
10
 
10
11
 
11
12
  Hoe.spec 'punkmaker' do
12
13
 
13
- self.version = '0.0.1'
14
+ self.version = Pixelart::Module::Punkmaker::VERSION
14
15
 
15
16
  self.summary = 'punkmaker gem - make your own (pixel) punk base (archetype) heads incl. humans, zombies, apes, aliens, mummies, robots, and much more'
16
17
  self.description = summary
17
18
 
18
- self.urls = { home: 'https://github.com/cryptopunksnotdead/cryptopunks' }
19
+ self.urls = { home: 'https://github.com/cryptopunksnotdead/punkart.sandbox' }
19
20
 
20
21
  self.author = 'Gerald Bauer'
21
22
  self.email = 'gerald.bauer@gmail.com'
@@ -25,7 +26,8 @@ Hoe.spec 'punkmaker' do
25
26
  self.history_file = 'CHANGELOG.md'
26
27
 
27
28
  self.extra_deps = [
28
- ['punks'],
29
+ ['pixelart'],
30
+ ['spritesheet'],
29
31
  ]
30
32
 
31
33
  self.licenses = ['Public Domain']
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,121 @@
1
+
2
+
3
+ module Punk
4
+ module Hair
5
+ def self.colors
6
+ @colors ||= begin
7
+ {
8
+ 'black' => '000000',
9
+
10
+ 'brown' => '51360c', # (darker) brown
11
+ 'brunette' => 'a66e2c', # lighter brown
12
+
13
+ 'orange' => 'e65700',
14
+ 'red' => 'e22626',
15
+ 'pink' => 'ff8ebe',
16
+ 'purple' => '710cc7',
17
+
18
+ 'green' => '28b143',
19
+
20
+ 'blonde' => 'fff68e',
21
+ 'silver' => 'e0e0e0',
22
+ 'white' => 'FFFFFF',
23
+ }.reduce( {} ) do |h, (name, color_hex)|
24
+ h[ name ] = Color.from_hex( color_hex )
25
+ h
26
+ end
27
+ end
28
+ @colors
29
+ end
30
+
31
+ def self.derive_color_map( color )
32
+ color = Color.parse( color ) if color.is_a?( String )
33
+
34
+ h,s,v = Color.to_hsv( color, include_alpha: false )
35
+ h = h % 360 ## make sure h(ue) is always positive!!!
36
+ puts " #{[h,s,v].inspect}"
37
+
38
+ # lighter - #2a2aff / rgb( 42 42 255) - hsl(240° 100% 58%) - hsv(240° 84% 100%)
39
+ # - used in hair( frumpy, f/pigtails3, f/straight3, f/wild4, f/wild5 )
40
+
41
+ # lightest - #5454ff / rgb( 84 84 255) - hsl(240° 100% 66%) - hsv(240° 67% 100%)
42
+ # - used in hair(mohawk thin)
43
+
44
+ # darker - #0000dd / rgb( 0 0 221) - hsl(240° 100% 43%) - hsv(240° 100% 87%)
45
+ # - used in hair(mohawk)
46
+
47
+ ## todo/fix: make lighter/darker formula more "robust"/ better!!!
48
+ if color == 0x000000ff # black
49
+ # hsv( 0° 0% 0%)
50
+ lighter = Color.from_hsv( h, 0.0, 0.16 )
51
+ lightest = Color.from_hsv( h, 0.0, 0.33 )
52
+ darker = Color.from_hsv( h, 0.0, 0.0 ) ## darker than black not possible ;-)
53
+ elsif color == 0xe0e0e0ff # silver
54
+ # hsv( 0° 0% 88%)
55
+ lighter = Color.from_hsv( h, 0.0, 1.0 ) # white
56
+ lightest = Color.from_hsv( h, 0.0, 1.0 ) # white
57
+ darker = Color.from_hsv( h, 0.0, [0.0, v-0.13].max )
58
+ elsif color == 0xffffffff # white
59
+ # hsv( 0° 0% 100%)
60
+ lighter = Color.from_hsv( h, 0.0, [0.0, v-0.11].max ) # note: make darker
61
+ lightest = Color.from_hsv( h, 0.0, 1.0 )
62
+ darker = Color.from_hsv( h, 0.0, [0.0, v-0.16].max )
63
+ else
64
+ lighter = Color.from_hsv( h, [0.0, s-0.16].max, v )
65
+ lightest = Color.from_hsv( h, [0.0, s-0.33].max, v )
66
+ darker = Color.from_hsv( h, s, [0.0, v-0.13].max )
67
+ end
68
+
69
+ color_map = {
70
+ '0000ffff' => color,
71
+ '2a2affff' => lighter,
72
+ '5454ffff' => lightest,
73
+ '0000ddff' => darker,
74
+ }
75
+ color_map
76
+ end # method self.derive_color_map
77
+
78
+ def self.colorize( hair, color: )
79
+ # "low-level" with no validity checks on hair image and passed in color (integer)
80
+ color_map = derive_color_map( color )
81
+ hair.change_colors( color_map )
82
+ end
83
+
84
+
85
+ class Maker ## rename to Factory or Studio or Generator or .. such - why? why not?
86
+ def self.read( image_path, meta_path, width:, height:, colors: )
87
+ sheet = Pixelart::Spritesheet.read( image_path, meta_path,
88
+ width: width,
89
+ height: height )
90
+ new( sheet, colors: colors )
91
+ end
92
+
93
+ attr_reader :sheet, :colors
94
+
95
+ def initialize( sheet, colors: )
96
+ @sheet = sheet
97
+ @colors = colors
98
+ end
99
+ def find_by( name: ) @sheet.find_by( name: name ); end
100
+
101
+ def make( style, color: 'black' ) ## change name to colorize - why? why not?
102
+ ## pass-through shavedhead (no colors - alpha only) - why? why not?
103
+ hair = @sheet.find_by( name: style )
104
+ if hair.nil?
105
+ puts "!! ERROR - unknow hair style >#{style}<; sorry"
106
+ exit 1
107
+ end
108
+
109
+ color_key = color.downcase.gsub(' ','')
110
+ rgba = @colors[ color_key ]
111
+ if rgba.nil?
112
+ puts "!! ERROR - unknow hair color >#{style}<; sorry"
113
+ exit 1
114
+ end
115
+
116
+ color_map = Hair.derive_color_map( rgba )
117
+ hair.change_colors( color_map )
118
+ end
119
+ end ## (embedded) class Maker
120
+ end # module Hair
121
+ end # module Punk
@@ -4,8 +4,9 @@ module Punk
4
4
 
5
5
  module Human ## make it a class - why? why not?
6
6
 
7
- BASE_M = Sheet.find_by( name: 'Male 4' )
8
- BASE_F = Sheet.find_by( name: 'Female 4' )
7
+ BASE_M = Image.read( "#{Pixelart::Module::Punkmaker.root}/config/human-male4.png" )
8
+ BASE_F = Image.read( "#{Pixelart::Module::Punkmaker.root}/config/human-female4.png" )
9
+
9
10
 
10
11
  def self.make( color,
11
12
  eye_color: nil,
@@ -3,8 +3,9 @@ module Punk
3
3
 
4
4
  module Mummy ## make it a class - why? why not?
5
5
 
6
- BASE_M = Sheet.find_by( name: 'Mummy' )
7
- BASE_F = Sheet.find_by( name: 'Mummy Female' )
6
+ BASE_M = Image.read( "#{Pixelart::Module::Punkmaker.root}/config/mummy-male.png" )
7
+ BASE_F = Image.read( "#{Pixelart::Module::Punkmaker.root}/config/mummy-female.png" )
8
+
8
9
 
9
10
  def self.make( color,
10
11
  eye_color: nil,
@@ -0,0 +1,24 @@
1
+ module Pixelart
2
+ module Module
3
+ module Punkmaker
4
+ MAJOR = 0
5
+ MINOR = 2
6
+ PATCH = 0
7
+ VERSION = [MAJOR,MINOR,PATCH].join('.')
8
+
9
+ def self.version
10
+ VERSION
11
+ end
12
+
13
+ def self.banner
14
+ "punkmaker/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] in (#{root})"
15
+ end
16
+
17
+ def self.root
18
+ File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
19
+ end
20
+
21
+ end # module Punkmaker
22
+ end # module Module
23
+ end # module Pixelart
24
+
data/lib/punkmaker.rb CHANGED
@@ -1,10 +1,18 @@
1
- require 'punks'
1
+ require 'pixelart'
2
+ require 'spritesheet'
2
3
 
3
4
 
5
+ require_relative 'punkmaker/version' ## let version always go first
6
+ ## more base / archetypes
4
7
  require_relative 'punkmaker/human'
5
8
  require_relative 'punkmaker/mummy'
6
9
 
10
+ ## more hair (incl. beards & eyebrows)
11
+ require_relative 'punkmaker/hair'
7
12
 
8
13
 
9
14
 
15
+ puts Pixelart::Module::Punkmaker.banner # say hello
16
+
17
+
10
18
 
metadata CHANGED
@@ -1,17 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: punkmaker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.2.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: 2023-04-20 00:00:00.000000000 Z
11
+ date: 2023-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: punks
14
+ name: pixelart
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: spritesheet
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - ">="
@@ -50,14 +64,14 @@ dependencies:
50
64
  requirements:
51
65
  - - "~>"
52
66
  - !ruby/object:Gem::Version
53
- version: '3.23'
67
+ version: '4.0'
54
68
  type: :development
55
69
  prerelease: false
56
70
  version_requirements: !ruby/object:Gem::Requirement
57
71
  requirements:
58
72
  - - "~>"
59
73
  - !ruby/object:Gem::Version
60
- version: '3.23'
74
+ version: '4.0'
61
75
  description: punkmaker gem - make your own (pixel) punk base (archetype) heads incl.
62
76
  humans, zombies, apes, aliens, mummies, robots, and much more
63
77
  email: gerald.bauer@gmail.com
@@ -72,10 +86,16 @@ files:
72
86
  - Manifest.txt
73
87
  - README.md
74
88
  - Rakefile
89
+ - config/human-female4.png
90
+ - config/human-male4.png
91
+ - config/mummy-female.png
92
+ - config/mummy-male.png
75
93
  - lib/punkmaker.rb
94
+ - lib/punkmaker/hair.rb
76
95
  - lib/punkmaker/human.rb
77
96
  - lib/punkmaker/mummy.rb
78
- homepage: https://github.com/cryptopunksnotdead/cryptopunks
97
+ - lib/punkmaker/version.rb
98
+ homepage: https://github.com/cryptopunksnotdead/punkart.sandbox
79
99
  licenses:
80
100
  - Public Domain
81
101
  metadata: {}
@@ -96,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
116
  - !ruby/object:Gem::Version
97
117
  version: '0'
98
118
  requirements: []
99
- rubygems_version: 3.3.7
119
+ rubygems_version: 3.4.10
100
120
  signing_key:
101
121
  specification_version: 4
102
122
  summary: punkmaker gem - make your own (pixel) punk base (archetype) heads incl. humans,