punkmaker 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -0
- data/Manifest.txt +1 -0
- data/README.md +6 -3
- data/Rakefile +5 -4
- data/lib/punkmaker/hair.rb +121 -0
- data/lib/punkmaker/version.rb +1 -1
- data/lib/punkmaker.rb +5 -1
- metadata +21 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6692eb9ea8a32eb0d6f104039bba563dec993e5bebc83b771e18095e48b5f0d
|
4
|
+
data.tar.gz: 39ef67f256eba06343e750875e39627e73962cf159d2a81b3fee71c44edd041f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10e1f2e5cb734d461c66586eea4b8312c7fdf1251ca03fe9b36b37851aadf308a03fd7322d05388f45041915ece2420da40b225e1f02afd6dff0410dcd7ee201
|
7
|
+
data.tar.gz: 5444664fa42726421e0ce510a69873249ac8d46b2c533dd7da118c429b49acdd1d8cc7a3b57873d660c51ad3ea6aacb12d9ae1eded5650435ff21d41f9b38ddd
|
data/CHANGELOG.md
CHANGED
data/Manifest.txt
CHANGED
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/
|
8
|
-
* bugs :: [github.com/cryptopunksnotdead/
|
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
|
-
|
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
@@ -4,9 +4,9 @@ require './lib/punkmaker/version.rb'
|
|
4
4
|
|
5
5
|
###
|
6
6
|
# hack/ quick fix for broken intuit_values - overwrite with dummy
|
7
|
-
class Hoe
|
8
|
-
def intuit_values( input ); end
|
9
|
-
end
|
7
|
+
# class Hoe
|
8
|
+
# def intuit_values( input ); end
|
9
|
+
# end
|
10
10
|
|
11
11
|
|
12
12
|
Hoe.spec 'punkmaker' do
|
@@ -16,7 +16,7 @@ Hoe.spec 'punkmaker' do
|
|
16
16
|
self.summary = 'punkmaker gem - make your own (pixel) punk base (archetype) heads incl. humans, zombies, apes, aliens, mummies, robots, and much more'
|
17
17
|
self.description = summary
|
18
18
|
|
19
|
-
self.urls = { home: 'https://github.com/cryptopunksnotdead/
|
19
|
+
self.urls = { home: 'https://github.com/cryptopunksnotdead/punkart.sandbox' }
|
20
20
|
|
21
21
|
self.author = 'Gerald Bauer'
|
22
22
|
self.email = 'gerald.bauer@gmail.com'
|
@@ -27,6 +27,7 @@ Hoe.spec 'punkmaker' do
|
|
27
27
|
|
28
28
|
self.extra_deps = [
|
29
29
|
['pixelart'],
|
30
|
+
['spritesheet'],
|
30
31
|
]
|
31
32
|
|
32
33
|
self.licenses = ['Public Domain']
|
@@ -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
|
data/lib/punkmaker/version.rb
CHANGED
data/lib/punkmaker.rb
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
require 'pixelart'
|
2
|
+
require 'spritesheet'
|
2
3
|
|
3
4
|
|
4
|
-
require_relative 'punkmaker/version'
|
5
|
+
require_relative 'punkmaker/version' ## let version always go first
|
6
|
+
## more base / archetypes
|
5
7
|
require_relative 'punkmaker/human'
|
6
8
|
require_relative 'punkmaker/mummy'
|
7
9
|
|
10
|
+
## more hair (incl. beards & eyebrows)
|
11
|
+
require_relative 'punkmaker/hair'
|
8
12
|
|
9
13
|
|
10
14
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: punkmaker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
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-
|
11
|
+
date: 2023-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pixelart
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: spritesheet
|
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'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rdoc
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,14 +64,14 @@ dependencies:
|
|
50
64
|
requirements:
|
51
65
|
- - "~>"
|
52
66
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
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: '
|
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
|
@@ -77,10 +91,11 @@ files:
|
|
77
91
|
- config/mummy-female.png
|
78
92
|
- config/mummy-male.png
|
79
93
|
- lib/punkmaker.rb
|
94
|
+
- lib/punkmaker/hair.rb
|
80
95
|
- lib/punkmaker/human.rb
|
81
96
|
- lib/punkmaker/mummy.rb
|
82
97
|
- lib/punkmaker/version.rb
|
83
|
-
homepage: https://github.com/cryptopunksnotdead/
|
98
|
+
homepage: https://github.com/cryptopunksnotdead/punkart.sandbox
|
84
99
|
licenses:
|
85
100
|
- Public Domain
|
86
101
|
metadata: {}
|
@@ -101,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
116
|
- !ruby/object:Gem::Version
|
102
117
|
version: '0'
|
103
118
|
requirements: []
|
104
|
-
rubygems_version: 3.
|
119
|
+
rubygems_version: 3.4.10
|
105
120
|
signing_key:
|
106
121
|
specification_version: 4
|
107
122
|
summary: punkmaker gem - make your own (pixel) punk base (archetype) heads incl. humans,
|