punkmaker 0.3.0 → 0.3.2

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.
@@ -6,21 +6,61 @@ module Zombie ## make it a class - why? why not?
6
6
  BASE_M = Image.read( "#{Pixelart::Module::Punkmaker.root}/config/zombie-male.png" )
7
7
  BASE_F = Image.read( "#{Pixelart::Module::Punkmaker.root}/config/zombie-female.png" )
8
8
 
9
- def self.make( color,
9
+ def self.make( color=nil,
10
+ shine: true,
10
11
  gender: 'm' )
11
- color_map = derive_color_map( color )
12
-
13
- punk = nil
12
+ base = gender == 'm' ? BASE_M : BASE_F
13
+
14
+ ## note: make a copy of base
15
+ punk = Image.new( base.width, base.height )
16
+ punk.compose!( base )
17
+
18
+ if color
19
+ color_map = derive_color_map( color )
20
+ punk = punk.change_colors( color_map )
21
+ end
22
+
23
+ if shine
24
+ shine_color = color ? derive_shine( color ) : 0x9bbc88ff
14
25
  if gender == 'm'
15
- punk = BASE_M.change_colors( color_map )
16
- else
17
- punk = BASE_F.change_colors( color_map )
26
+ punk[9,7] = shine_color
27
+ punk[8,8] = shine_color
28
+ else
29
+ punk[9,9] = shine_color
18
30
  end
19
- punk
31
+ end
32
+
33
+ punk
20
34
  end
35
+
36
+
37
+ def self.derive_shine( color )
38
+ ## was before - reuse - why? why not?
39
+ ## todo/check - check "formula" used in skintones script for humans!!!
40
+ ## lighter = Color.from_hsl(
41
+ ## (h+1)%360, # todo/check: make lighter by -1 on hue? or +1????
42
+ ## [1.0,s+0.10].min,
43
+ ## [1.0,l+0.25].min)
44
+
45
+ color = Color.from_hex( color ) if color.is_a?( String )
46
+
47
+ hsv = Color.to_hsv( color )
48
+ # pp hsv
49
+
50
+ h, s, v = hsv
51
+ h = h % 360 # make always positive (might be -50 or such)
52
+ ## pp [h,s,v]
53
+
54
+ ## add extra saturation if v(alue) / brightness is max 1.0 - why? why not?
55
+ sdiff = v >= 0.99 ? 0.25 : 0.15
56
+
57
+ lighter = Color.from_hsv( h, [0.0, s-sdiff].max, [v+0.1,1.0].min )
58
+ lighter
59
+ end
60
+
21
61
 
22
62
  def self.derive_color_map( color )
23
- color = Color.parse( color ) if color.is_a?( String )
63
+ color = Color.from_hex( color ) if color.is_a?( String )
24
64
 
25
65
  # 2 pixels #9bbc88 / rgb(155 188 136) - hsl( 98° 28% 64%) - lighter
26
66
  # 125 pixels #7da269 / rgb(125 162 105) - hsl( 99° 23% 52%) - base (use as base)
@@ -40,17 +80,10 @@ module Zombie ## make it a class - why? why not?
40
80
  [0.0,s-0.05].max,
41
81
  [0.0,l-0.12].max)
42
82
 
43
- ## todo/check - check "formula" used in skintones script for humans!!!
44
- lighter = Color.from_hsl(
45
- (h+1)%360, # todo/check: make lighter by -1 on hue? or +1????
46
- [1.0,s+0.10].min,
47
- [1.0,l+0.25].min)
48
-
49
83
 
50
84
  color_map = {
51
85
  '#7da269' => base,
52
86
  '#5e7253' => darker,
53
- '#9bbc88' => lighter
54
87
  }
55
88
 
56
89
  color_map
data/lib/punkmaker.rb CHANGED
@@ -4,6 +4,10 @@ require 'spritesheet'
4
4
 
5
5
  require_relative 'punkmaker/version' ## let version always go first
6
6
 
7
+ ## support - move to ???
8
+ require_relative 'punkmaker/colors' ## ColorBundle (color by name lookup and mroe)
9
+ require_relative 'punkmaker/skintone'
10
+
7
11
  ## more base / archetypes
8
12
  require_relative 'punkmaker/human'
9
13
  require_relative 'punkmaker/alien'
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.3.0
4
+ version: 0.3.2
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-08-31 00:00:00.000000000 Z
11
+ date: 2023-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pixelart
@@ -102,6 +102,10 @@ files:
102
102
  - config/robot-male.png
103
103
  - config/skeleton-female.png
104
104
  - config/skeleton-male.png
105
+ - config/skintone/color_me_human.csv
106
+ - config/skintone/dr_ellis_monk.csv
107
+ - config/skintone/punks_not_dead.csv
108
+ - config/skintone/ye_olde_punks.csv
105
109
  - config/vampire-female.png
106
110
  - config/vampire-male.png
107
111
  - config/zombie-female.png
@@ -109,6 +113,7 @@ files:
109
113
  - lib/punkmaker.rb
110
114
  - lib/punkmaker/alien.rb
111
115
  - lib/punkmaker/ape.rb
116
+ - lib/punkmaker/colors.rb
112
117
  - lib/punkmaker/demon.rb
113
118
  - lib/punkmaker/hair.rb
114
119
  - lib/punkmaker/human.rb
@@ -116,6 +121,7 @@ files:
116
121
  - lib/punkmaker/orc.rb
117
122
  - lib/punkmaker/robot.rb
118
123
  - lib/punkmaker/skeleton.rb
124
+ - lib/punkmaker/skintone.rb
119
125
  - lib/punkmaker/vampire.rb
120
126
  - lib/punkmaker/version.rb
121
127
  - lib/punkmaker/zombie.rb