Class | Rubygame::Color::ColorHSV |
In: |
lib/rubygame/color/models/hsv.rb
|
Parent: | Object |
Represents color in the HSV (Hue, Saturation, Value) color space.
a | [R] | |
h | [R] | |
s | [R] | |
v | [R] |
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
# File lib/rubygame/color/models/hsv.rb, line 64 def new_from_rgba( rgba ) new( rgba_to_hsva(*rgba) ) end
# 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