# File lib/cairo/color.rb, line 99 def ==(other) other.is_a?(self.class) and other.to_s == to_s end
# File lib/cairo/color.rb, line 95 def eql?(other) self == other end
# File lib/cairo/color.rb, line 103 def to_a [@red, @green, @blue, @alpha] end
# File lib/cairo/color.rb, line 116 def to_cmyk cmy = [1.0 - @red, 1.0 - @green, 1.0 - @blue] key_plate = cmy.min if key_plate < 1.0 one_k = 1.0 - key_plate cmyk = cmy.collect {|value| (value - key_plate) / one_k} + [key_plate] else cmyk = [0, 0, 0, key_plate] end cmyka = cmyk + [@alpha] CMYK.new(*cmyka) end
# File lib/cairo/color.rb, line 129 def to_hsv max = [@red, @blue, @green].max if max > 0 min = [@red, @blue, @green].min max_min = max - min case max when @red numerator = @green - @blue angle = 0 when @green numerator = @blue - @red angle = 120 when @blue numerator = @red - @green angle = 240 end h = max_min > 0 ? 60 * numerator / max_min + angle : 0.0 s = max_min / max else h = 0.0 s = 0.0 end v = max HSV.new(h, s, v, @alpha) end
Generated with the Darkfish Rdoc Generator 2.