punkmaker 0.3.0 → 0.3.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: '090cd7aef96630d9965d356c07f5ee4ee2f10646e004ce04d33b818e6f14fe9d'
4
- data.tar.gz: 18845296d5fb06f19ade59f9b9b247bd6e8034ee1a3b9771e4144eb08e98e282
3
+ metadata.gz: 44a12cf90683dcbdc1289eb5272daa165010d4e86bd0c31c9eca9d9f6cbfef42
4
+ data.tar.gz: 83ea621299ee91bd119ac9583cfc7df5b75ff0efe2e02b5e50e6225f9ba721a3
5
5
  SHA512:
6
- metadata.gz: 9fae8313d6eb3617e4a24815dfa2ace0edd8a06ff878583425bb9611e0adea29a033ab7c143639fbfffc4c82a064b56e4e92255ca03184297870806b5e8b0794
7
- data.tar.gz: 47ac27f962d02de05919e42b1289e4acb06723548ac66c32277f1fd0a718b62e1fd72e1accac07eeb74c49c0e6bbf9f3fb0ddd76f0b8be94093b2a762a97f4fd
6
+ metadata.gz: 5e94379084c7172fc7be35986e4f9033287ef42a99bd9aac91c7e2c50087b928051463c6c2e1c615e4b620c72f225158f16b642cad895343b65a1adf75bfbd3d
7
+ data.tar.gz: 93fe49aeb67af85fd2fea30d79db2deced0931e38f05ae8d7bbc2b916ab72f02af3568a90989dad8d0ce2246b21308209ecdd969597772c9e2943dabf5034696
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ### 0.3.0
1
+ ### 0.3.1
2
2
  ### 0.0.1 / 2023-04-20
3
3
 
4
4
  * Everything is new. First release
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -8,19 +8,60 @@ module Alien ## make it a class - why? why not?
8
8
  BASE_F = Image.read( "#{Pixelart::Module::Punkmaker.root}/config/alien-female.png" )
9
9
 
10
10
 
11
- def self.make( color,
11
+ def self.make( color=nil,
12
+ shine: true,
12
13
  gender: 'm' )
13
- color_map = derive_color_map( color )
14
14
 
15
- punk = nil
16
- if gender == 'm'
17
- punk = BASE_M.change_colors( color_map )
18
- else
19
- punk = BASE_F.change_colors( color_map )
15
+ base = gender == 'm' ? BASE_M : BASE_F
16
+
17
+ ## note: make a copy of base
18
+ punk = Image.new( base.width, base.height )
19
+ punk.compose!( base )
20
+
21
+ if color ## change skin tone (& eyebrows)?
22
+ color_map = derive_color_map( color )
23
+ punk = punk.change_colors( color_map )
20
24
  end
25
+
26
+
27
+ if shine
28
+ shine_color = color ? derive_shine( color ) : 0xf1ffffff
29
+ if gender == 'm'
30
+ punk[9,7] = shine_color
31
+ punk[8,8] = shine_color
32
+ else
33
+ punk[9,9] = shine_color
34
+ end
35
+ end
21
36
  punk
22
37
  end
23
38
 
39
+
40
+ def self.derive_shine( color )
41
+ ## was before - reuse old formula- why? why not?
42
+ ## todo/check - check "formula" used in skintones script for humans!!!
43
+ ## lighter = Color.from_hsl(
44
+ ## (h+1)%360, # todo/check: make lighter by -1 on hue? or +1????
45
+ ## [1.0,s+0.10].min,
46
+ ## [1.0,l+0.25].min)
47
+
48
+ color = Color.parse( color ) if color.is_a?( String )
49
+
50
+ hsv = Color.to_hsv( color )
51
+ # pp hsv
52
+
53
+ h, s, v = hsv
54
+ h = h % 360 # make always positive (might be -50 or such)
55
+ ## pp [h,s,v]
56
+
57
+ ## add extra saturation if v(alue) / brightness is max 1.0 - why? why not?
58
+ sdiff = v >= 0.99 ? 0.35 : 0.25
59
+
60
+ lighter = Color.from_hsv( h, [0.0, s-sdiff].max, [v+0.1,1.0].min )
61
+ lighter
62
+ end
63
+
64
+
24
65
 
25
66
  def self.derive_color_map( color )
26
67
 
@@ -38,12 +79,6 @@ h, s, l = hsl
38
79
  h = h % 360 # make always positive (might be -50 or such)
39
80
  pp [h,s,l]
40
81
 
41
- ## todo/check - check "formula" used in skintones script for humans!!!
42
- lighter = Color.from_hsl(
43
- (h+1)%360, # todo/check: make lighter by -1 on hue? or +1????
44
- [1.0,s+0.10].min,
45
- [1.0,l+0.25].min)
46
-
47
82
 
48
83
  darker = Color.from_hsl(
49
84
  h,
@@ -58,7 +93,6 @@ darkest = Color.from_hsl(
58
93
 
59
94
  color_map = {
60
95
  '#c8fbfb' => base,
61
- '#f1ffff' => lighter,
62
96
  '#9be0e0' => darker,
63
97
  '#75bdbd' => darkest,
64
98
  }
data/lib/punkmaker/ape.rb CHANGED
@@ -6,18 +6,21 @@ module Ape ## make it a class - why? why not?
6
6
  BASE_M = Image.read( "#{Pixelart::Module::Punkmaker.root}/config/ape-male.png" )
7
7
  BASE_F = Image.read( "#{Pixelart::Module::Punkmaker.root}/config/ape-female.png" )
8
8
 
9
- def self.make( color,
9
+ def self.make( color=nil,
10
10
  gender: 'm' )
11
- color_map = derive_color_map( color )
12
-
13
- punk = nil
14
- if gender == 'm'
15
- punk = BASE_M.change_colors( color_map )
16
- else
17
- punk = BASE_F.change_colors( color_map )
18
- end
19
- punk
20
- end
11
+ base = gender == 'm' ? BASE_M : BASE_F
12
+
13
+ ## note: make a copy of base
14
+ punk = Image.new( base.width, base.height )
15
+ punk.compose!( base )
16
+
17
+ if color
18
+ color_map = derive_color_map( color )
19
+ punk = punk.change_colors( color_map )
20
+ end
21
+
22
+ punk
23
+ end
21
24
 
22
25
  def self.derive_color_map( color )
23
26
  color = Color.parse( color ) if color.is_a?( String )
@@ -6,17 +6,21 @@ module Demon ## make it a class - why? why not?
6
6
  BASE_M = Image.read( "#{Pixelart::Module::Punkmaker.root}/config/demon-male.png" )
7
7
  BASE_F = Image.read( "#{Pixelart::Module::Punkmaker.root}/config/demon-female.png" )
8
8
 
9
- def self.make( color,
9
+ def self.make( color=nil,
10
10
  gender: 'm' )
11
- color_map = derive_color_map( color )
12
-
13
- punk = nil
14
- if gender == 'm'
15
- punk = BASE_M.change_colors( color_map )
16
- else
17
- punk = BASE_F.change_colors( color_map )
18
- end
19
- punk
11
+ base = gender == 'm' ? BASE_M : BASE_F
12
+
13
+ ## note: make a copy of base
14
+ punk = Image.new( base.width, base.height )
15
+ punk.compose!( base )
16
+
17
+ if color
18
+ color_map = derive_color_map( color )
19
+ punk = punk.change_colors( color_map )
20
+ end
21
+
22
+ punk
23
+
20
24
  end
21
25
 
22
26
  def self.derive_color_map( color )
@@ -8,45 +8,72 @@ module Human ## make it a class - why? why not?
8
8
  BASE_F = Image.read( "#{Pixelart::Module::Punkmaker.root}/config/human-female4.png" )
9
9
 
10
10
 
11
- def self.make( color,
11
+ def self.make( color=nil,
12
+ shine: true,
12
13
  eye_color: nil,
13
14
  gender: 'm' )
14
- color_map = derive_color_map( color )
15
-
16
- eye_color = Color.parse( eye_color ) if eye_color && eye_color.is_a?( String )
17
-
18
- punk = nil
19
- if gender == 'm'
20
- punk = BASE_M.change_colors( color_map )
21
- punk[10,12] = Color::WHITE # left eye dark-ish pixel to white
22
- punk[15,12] = Color::WHITE # right eye ---
23
- if eye_color
24
- punk[9,12] = eye_color
25
- punk[14,12] = eye_color
26
- end
27
- else ## assume 'f'
28
- ## for female - change lips to all black (like in male for now) - why? why not?
29
- color_map[ '#711010' ] = '#000000'
30
- punk = BASE_F.change_colors( color_map )
31
- punk[10,13] = Color::WHITE # left eye dark-ish pixel to white
32
- punk[15,13] = Color::WHITE # right eye ---
33
- if eye_color
34
- punk[9,13] = eye_color
35
- punk[14,13] = eye_color
36
- end
15
+
16
+ base = gender == 'm' ? BASE_M : BASE_F
17
+
18
+ ## note: make a copy of base
19
+ punk = Image.new( base.width, base.height )
20
+ punk.compose!( base )
21
+
22
+ if color ## change skin tone (& eyebrows)?
23
+ color_map = derive_color_map( color )
24
+ punk = punk.change_colors( color_map )
25
+ end
26
+
27
+ if eye_color ## change eye color?
28
+ eye_color = Color.parse( eye_color ) if eye_color.is_a?( String )
29
+ if gender == 'm'
30
+ punk[9,12] = eye_color
31
+ punk[14,12] = eye_color
32
+ else
33
+ punk[9,13] = eye_color
34
+ punk[14,13] = eye_color
35
+ end
36
+ end
37
+
38
+ if shine ## add shine?
39
+ # note: default shine color is white
40
+ shine_color = color ? derive_shine( color ) : 0xffffffff
41
+ if gender == 'm'
42
+ punk[9,7] = shine_color
43
+ punk[8,8] = shine_color
44
+ else
45
+ punk[9,9] = shine_color
46
+ end
37
47
  end
38
48
 
39
49
  punk
40
50
  end
41
51
 
42
52
 
53
+ def self.derive_shine( color )
54
+ color = Color.parse( color ) if color.is_a?( String )
55
+
56
+ hsv = Color.to_hsv( color )
57
+ # pp hsv
58
+
59
+ h, s, v = hsv
60
+ h = h % 360 # make always positive (might be -50 or such)
61
+ ## pp [h,s,v]
62
+
63
+ ## add extra saturation if v(alue) / brightness is max 1.0 - why? why not?
64
+ sdiff = v >= 0.99 ? 0.25 : 0.15
65
+
66
+ lighter = Color.from_hsv( h, [0.0, s-sdiff].max, [v+0.1,1.0].min )
67
+ lighter
68
+ end
69
+
70
+
43
71
  ##
44
72
  ## todo/check:
45
73
  ## add a derive_colors or dervice_skintones method - why? why not?
46
74
  ## - change to name skintone_palette - why? why not?
47
75
  ## def self.derive_skintone_colors( color or base ) ???
48
76
 
49
-
50
77
  def self.derive_color_map( color )
51
78
  color = Color.parse( color ) if color.is_a?( String )
52
79
 
@@ -59,28 +86,16 @@ module Human ## make it a class - why? why not?
59
86
  h = h % 360 # make always positive (might be -50 or such)
60
87
  pp [h,s,l]
61
88
 
62
- darker = Color.from_hsl(
63
- h,
64
- [0.0, s-0.05].max,
65
- [0.14, l-0.1].max)
66
-
67
89
  ## sub one degree on hue on color wheel (plus +10% on lightness??)
68
- darkest = Color.from_hsl(
69
- (h-1) % 360,
90
+ ## darker
91
+ eyebrows = Color.from_hsl(
92
+ h,
70
93
  s,
71
94
  [0.05, l-0.1].max)
72
95
 
73
-
74
- lighter = Color.from_hsl(
75
- (h+1) % 360,
76
- s,
77
- [1.0, l+0.1].min)
78
-
79
96
  color_map = {
80
97
  '#ead9d9' => base,
81
- '#ffffff' => lighter,
82
- '#a58d8d' => darkest,
83
- '#c9b2b2' => darker
98
+ '#a58d8d' => eyebrows,
84
99
  }
85
100
  color_map
86
101
  end
@@ -7,29 +7,34 @@ module Punk
7
7
  BASE_F = Image.read( "#{Pixelart::Module::Punkmaker.root}/config/mummy-female.png" )
8
8
 
9
9
 
10
- def self.make( color,
10
+ def self.make( color=nil,
11
11
  eye_color: nil,
12
12
  gender: 'm' )
13
- color_map = derive_color_map( color )
13
+ base = gender == 'm' ? BASE_M : BASE_F
14
+
15
+ ## note: make a copy of base
16
+ punk = Image.new( base.width, base.height )
17
+ punk.compose!( base )
18
+
19
+ if color
20
+ color_map = derive_color_map( color )
21
+ punk = punk.change_colors( color_map )
22
+ end
14
23
 
15
- eye_color = Color.parse( eye_color ) if eye_color && eye_color.is_a?( String )
24
+ if eye_color
25
+ eye_color = Color.parse( eye_color ) if eye_color.is_a?( String )
16
26
 
17
- punk = nil
18
27
  if gender == 'm'
19
- punk = BASE_M.change_colors( color_map )
20
- if eye_color
21
28
  punk[9,12] = eye_color
22
29
  punk[14,12] = eye_color
23
- end
24
30
  else ## assume 'f'
25
- punk = BASE_F.change_colors( color_map )
26
- if eye_color
27
31
  punk[10,13] = eye_color ## note: eye pos +1 pix!!
28
32
  punk[14,13] = eye_color
29
- end
30
33
  end
31
- punk
32
34
  end
35
+ punk
36
+ end
37
+
33
38
 
34
39
  def self.derive_color_map( color )
35
40
  color = Color.parse( color ) if color.is_a?( String )
data/lib/punkmaker/orc.rb CHANGED
@@ -6,17 +6,20 @@ module Orc ## make it a class - why? why not?
6
6
  BASE_M = Image.read( "#{Pixelart::Module::Punkmaker.root}/config/orc-male.png" )
7
7
  BASE_F = Image.read( "#{Pixelart::Module::Punkmaker.root}/config/orc-female.png" )
8
8
 
9
- def self.make( color,
9
+ def self.make( color=nil,
10
10
  gender: 'm' )
11
- color_map = derive_color_map( color )
12
-
13
- punk = nil
14
- if gender == 'm'
15
- punk = BASE_M.change_colors( color_map )
16
- else
17
- punk = BASE_F.change_colors( color_map )
18
- end
19
- punk
11
+ base = gender == 'm' ? BASE_M : BASE_F
12
+
13
+ ## note: make a copy of base
14
+ punk = Image.new( base.width, base.height )
15
+ punk.compose!( base )
16
+
17
+ if color
18
+ color_map = derive_color_map( color )
19
+ punk = punk.change_colors( color_map )
20
+ end
21
+
22
+ punk
20
23
  end
21
24
 
22
25
  def self.derive_color_map( color )
@@ -6,17 +6,20 @@ module Robot ## make it a class - why? why not?
6
6
  BASE_M = Image.read( "#{Pixelart::Module::Punkmaker.root}/config/robot-male.png" )
7
7
  BASE_F = Image.read( "#{Pixelart::Module::Punkmaker.root}/config/robot-female.png" )
8
8
 
9
- def self.make( color,
9
+ def self.make( color=nil,
10
10
  gender: 'm' )
11
- color_map = derive_color_map( color )
12
-
13
- punk = nil
14
- if gender == 'm'
15
- punk = BASE_M.change_colors( color_map )
16
- else
17
- punk = BASE_F.change_colors( color_map )
18
- end
19
- punk
11
+ base = gender == 'm' ? BASE_M : BASE_F
12
+
13
+ ## note: make a copy of base
14
+ punk = Image.new( base.width, base.height )
15
+ punk.compose!( base )
16
+
17
+ if color
18
+ color_map = derive_color_map( color )
19
+ punk = punk.change_colors( color_map )
20
+ end
21
+
22
+ punk
20
23
  end
21
24
 
22
25
  def self.derive_color_map( color )
@@ -5,17 +5,20 @@ module Skeleton ## make it a class - why? why not?
5
5
  BASE_M = Image.read( "#{Pixelart::Module::Punkmaker.root}/config/skeleton-male.png" )
6
6
  BASE_F = Image.read( "#{Pixelart::Module::Punkmaker.root}/config/skeleton-female.png" )
7
7
 
8
- def self.make( color,
8
+ def self.make( color=nil,
9
9
  gender: 'm' )
10
- color_map = derive_color_map( color )
11
-
12
- punk = nil
13
- if gender == 'm'
14
- punk = BASE_M.change_colors( color_map )
15
- else
16
- punk = BASE_F.change_colors( color_map )
17
- end
18
- punk
10
+ base = gender == 'm' ? BASE_M : BASE_F
11
+
12
+ ## note: make a copy of base
13
+ punk = Image.new( base.width, base.height )
14
+ punk.compose!( base )
15
+
16
+ if color
17
+ color_map = derive_color_map( color )
18
+ punk = punk.change_colors( color_map )
19
+ end
20
+
21
+ punk
19
22
  end
20
23
 
21
24
  def self.derive_color_map( color )
@@ -6,17 +6,20 @@ module Vampire ## make it a class - why? why not?
6
6
  BASE_M = Image.read( "#{Pixelart::Module::Punkmaker.root}/config/vampire-male.png" )
7
7
  BASE_F = Image.read( "#{Pixelart::Module::Punkmaker.root}/config/vampire-female.png" )
8
8
 
9
- def self.make( color,
9
+ def self.make( color=nil,
10
10
  gender: 'm' )
11
- color_map = derive_color_map( color )
12
-
13
- punk = nil
14
- if gender == 'm'
15
- punk = BASE_M.change_colors( color_map )
16
- else
17
- punk = BASE_F.change_colors( color_map )
18
- end
19
- punk
11
+ base = gender == 'm' ? BASE_M : BASE_F
12
+
13
+ ## note: make a copy of base
14
+ punk = Image.new( base.width, base.height )
15
+ punk.compose!( base )
16
+
17
+ if color
18
+ color_map = derive_color_map( color )
19
+ punk = punk.change_colors( color_map )
20
+ end
21
+
22
+ punk
20
23
  end
21
24
 
22
25
  def self.derive_color_map( color )
@@ -3,7 +3,7 @@ module Pixelart
3
3
  module Punkmaker
4
4
  MAJOR = 0
5
5
  MINOR = 3
6
- PATCH = 0
6
+ PATCH = 1
7
7
  VERSION = [MAJOR,MINOR,PATCH].join('.')
8
8
 
9
9
  def self.version
@@ -6,18 +6,58 @@ 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
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.parse( 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
20
59
  end
60
+
21
61
 
22
62
  def self.derive_color_map( color )
23
63
  color = Color.parse( color ) if color.is_a?( String )
@@ -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
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.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: 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