Class: SGL::ColorTranslatorRGB
- Inherits:
-
Object
- Object
- SGL::ColorTranslatorRGB
- Defined in:
- lib/sgl/sgl-color.rb
Instance Method Summary collapse
-
#initialize(r = nil, g = nil, b = nil, a = nil) ⇒ ColorTranslatorRGB
constructor
A new instance of ColorTranslatorRGB.
- #norm(r, g = nil, b = nil, a = nil) ⇒ Object
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 |