# class Cairo::Color::HSV

### Attributes

h[RW]
h=[RW]
hue[RW]
s[RW]
s=[RW]
saturation[RW]
v[RW]
v=[RW]
value[RW]

### Public Class Methods

new(h, s, v, a=1.0) click to toggle source
Calls superclass method Cairo::Color::Base.new

    # File lib/cairo/color.rb, line 215
    def initialize(h, s, v, a=1.0)
      super(a)
      assert_in_range(s, "saturation")
      assert_in_range(v, "value")
      @hue = h.modulo(360.0)
      @saturation = s
      @value = v
    end

### Public Instance Methods

to_a() click to toggle source

    # File lib/cairo/color.rb, line 224
    def to_a
      [@hue, @saturation, @value, @alpha]
    end

Also aliased as: to_ary
to_ary()
Alias for: to_a
to_cmyk() click to toggle source

    # File lib/cairo/color.rb, line 258
    def to_cmyk
      to_rgb.to_cmyk
    end

to_hsv() click to toggle source

    # File lib/cairo/color.rb, line 262
    def to_hsv
      clone
    end

to_rgb() click to toggle source

    # File lib/cairo/color.rb, line 229
    def to_rgb
      if s > 0
        h_60 = @hue / 60.0
        hi = h_60.floor.modulo(6)
        f = h_60 - hi
        p = @value * (1 - @saturation)
        q = @value * (1 - f * @saturation)
        t = @value * (1 - (1 - f) * @saturation)
        case hi
        when 0
          rgb = [@value, t, p]
        when 1
          rgb = [q, @value, p]
        when 2
          rgb = [p, @value, t]
        when 3
          rgb = [p, q, @value]
        when 4
          rgb = [t, p, @value]
        when 5
          rgb = [@value, p, q]
        end
        rgba = rgb + [@alpha]
        RGB.new(*rgba)
      else
        RGB.new(@value, @value, @value, @alpha)
      end
    end