Class Rubygame::Color::ColorHSL
In: lib/rubygame/color/models/hsl.rb
Parent: Object

Represents color in the HSL (Hue, Saturation, Luminosity) color space.

Methods

Included Modules

ColorBase

Attributes

a  [R] 
h  [R] 
l  [R] 
s  [R] 

Public Class methods

Create a new instance from an Array or an existing color (of any type). If the alpha (opacity) component is omitted from the array, full opacity will be used.

All color components range from 0.0 to 1.0.

[Source]

# File lib/rubygame/color/models/hsl.rb, line 42
                        def initialize( color )
                                if color.kind_of?(Array)
                                        @h, @s, @l, @a = color.collect { |i| i.to_f }
                                        @a = 1.0 unless @a
                                elsif color.respond_to?(:to_rgba_ary)
                                        @h, @s, @l, @a = self.class.rgba_to_hsla( *color.to_rgba_ary )
                                end
                        end

[Source]

# File lib/rubygame/color/models/hsl.rb, line 64
                                def new_from_rgba( rgba )
                                        new( rgba_to_hsla(*rgba) )
                                end

[Source]

# File lib/rubygame/color/models/hsl.rb, line 68
                                def new_from_sdl_rgba( rgba )
                                        new_from_rgba( rgba.collect { |i| i / 255.0 } )
                                end

Public Instance methods

inspect()

Alias for to_s

Return an Array with the red, green, blue, and alpha components of the color (converting the color to the RGBA model first).

[Source]

# File lib/rubygame/color/models/hsl.rb, line 53
                        def to_rgba_ary
                                return self.class.hsla_to_rgba( @h, @s, @l, @a )
                        end

[Source]

# File lib/rubygame/color/models/hsl.rb, line 57
                        def to_s
                                "#<#{self.class} [#{@h}, #{@s}, #{@l}, #{@a}]>"
                        end

[Validate]