class Rubygame::Color::ColorHSL
Represents color in the HSL (Hue, Saturation, Luminosity) color space.
Attributes
a[R]
h[R]
l[R]
s[R]
Public Class Methods
new( [h,s,l,a] ) → ColorHSL
click to toggle source
new( [h,s,l] ) → ColorHSL
new( color ) → ColorHSL
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.
# 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
new_from_rgba( rgba )
click to toggle source
# File lib/rubygame/color/models/hsl.rb, line 64 def new_from_rgba( rgba ) new( rgba_to_hsla(*rgba) ) end
new_from_sdl_rgba( rgba )
click to toggle 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
to_rgba_ary()
click to toggle source
Return an Array with the red, green, blue, and alpha components of the color (converting the color to the RGBA model first).
# File lib/rubygame/color/models/hsl.rb, line 53 def to_rgba_ary return self.class.hsla_to_rgba( @h, @s, @l, @a ) end
to_s()
click to toggle source
# File lib/rubygame/color/models/hsl.rb, line 57 def to_s "#<#{self.class} [#{@h}, #{@s}, #{@l}, #{@a}]>" end
Also aliased as: inspect