Method: Punk::Alien.derive_shine

Defined in:
lib/punkmaker/type/alien.rb

.derive_shine(color) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/punkmaker/type/alien.rb', line 46

def self.derive_shine( color )
## was before - reuse old formula- why? why not?
## todo/check - check "formula" used in skintones script for humans!!!
## lighter = Color.from_hsl(
##   (h+1)%360,   # todo/check: make lighter by -1 on hue? or +1????
##   [1.0,s+0.10].min,
##   [1.0,l+0.25].min)

  color = Color.from_hex( color )  if color.is_a?( String )

  hsv  = Color.to_hsv( color )
  # pp hsv

  h, s, v = hsv
  h = h % 360   # make always positive (might be -50 or such)
  ## pp [h,s,v]

  ## add extra saturation if v(alue) / brightness is max 1.0 - why? why not?
  sdiff = v >= 0.99 ? 0.35 : 0.25

  lighter =  Color.from_hsv( h, [0.0, s-sdiff].max, [v+0.1,1.0].min )  
  lighter
end