Class: SGL::ColorTranslatorRGB

Inherits:
Object
  • Object
show all
Defined in:
lib/sgl/sgl-color.rb

Instance Method Summary collapse

Constructor Details

#initialize(r = nil, g = nil, b = nil, a = nil) ⇒ ColorTranslatorRGB

Returns a new instance of ColorTranslatorRGB.



13
14
15
16
17
18
# File 'lib/sgl/sgl-color.rb', line 13

def initialize(r=nil, g=nil, b=nil, a=nil)
  a = DEFAULT_MAX if a == nil
  r = DEFAULT_MAX if r == nil
  g = b = r if g == nil || b == nil
  @rm, @gm, @bm, @am = r.to_f, g.to_f, b.to_f, a.to_f
end

Instance Method Details

#norm(r, g = nil, b = nil, a = nil) ⇒ Object



20
21
22
23
24
# File 'lib/sgl/sgl-color.rb', line 20

def norm(r, g=nil, b=nil, a=nil)
  a = DEFAULT_MAX if a == nil
  g = b = r if g == nil || b == nil
  return [r/@rm, g/@gm, b/@bm, a/@am]
end