class Rubygame::Color::ColorHSV

Represents color in the HSV (Hue, Saturation, Value) color space.

Attributes

a[R]
h[R]
s[R]
v[R]

Public Class Methods

new( [h,s,v,a] ) → ColorHSV click to toggle source
new( [h,s,v] ) → ColorHSV
new( color ) → ColorHSV

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/hsv.rb, line 42
def initialize( color )
        if color.kind_of?(Array)
                @h, @s, @v, @a = color.collect { |i| i.to_f }
                @a = 1.0 unless @a
        elsif color.respond_to?(:to_rgba_ary)
                @h, @s, @v, @a = self.class.rgba_to_hsva( *color.to_rgba_ary )
        end
end
new_from_rgba( rgba ) click to toggle source
# File lib/rubygame/color/models/hsv.rb, line 64
def new_from_rgba( rgba )
        new( rgba_to_hsva(*rgba) )
end
new_from_sdl_rgba( rgba ) click to toggle source
# File lib/rubygame/color/models/hsv.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
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/hsv.rb, line 53
def to_rgba_ary
        return self.class.hsva_to_rgba( @h, @s, @v, @a )
end
to_s() click to toggle source
# File lib/rubygame/color/models/hsv.rb, line 57
def to_s
        "#<#{self.class} [#{@h}, #{@s}, #{@v}, #{@a}]>"
end
Also aliased as: inspect