Class: Cairo::Color::CMYK

Inherits:
Base
  • Object
show all
Defined in:
lib/cairo/color.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#alpha

Instance Method Summary collapse

Constructor Details

#initialize(c, m, y, k, a = 1.0) ⇒ CMYK

Returns a new instance of CMYK.



168
169
170
171
172
173
174
175
176
177
178
# File 'lib/cairo/color.rb', line 168

def initialize(c, m, y, k, a=1.0)
  super(a)
  assert_in_range(c, "cyan")
  assert_in_range(m, "magenta")
  assert_in_range(y, "yellow")
  assert_in_range(k, "key plate")
  @cyan = c
  @magenta = m
  @yellow = y
  @key_plate = k
end

Instance Attribute Details

#cyanObject Also known as: c

Returns the value of attribute cyan.



157
158
159
# File 'lib/cairo/color.rb', line 157

def cyan
  @cyan
end

#key_plateObject Also known as: k

Returns the value of attribute key_plate.



157
158
159
# File 'lib/cairo/color.rb', line 157

def key_plate
  @key_plate
end

#magentaObject Also known as: m

Returns the value of attribute magenta.



157
158
159
# File 'lib/cairo/color.rb', line 157

def magenta
  @magenta
end

#yellowObject Also known as: y

Returns the value of attribute yellow.



157
158
159
# File 'lib/cairo/color.rb', line 157

def yellow
  @yellow
end

Instance Method Details

#to_aObject Also known as: to_ary



180
181
182
# File 'lib/cairo/color.rb', line 180

def to_a
  [@cyan, @magenta, @yellow, @key_plate, @alpha]
end

#to_cmykObject



196
197
198
# File 'lib/cairo/color.rb', line 196

def to_cmyk
  clone
end

#to_hsvObject



200
201
202
# File 'lib/cairo/color.rb', line 200

def to_hsv
  to_rgb.to_hsv
end

#to_rgbObject



185
186
187
188
189
190
191
192
193
194
# File 'lib/cairo/color.rb', line 185

def to_rgb
  one_k = 1.0 - @key_plate
  rgba = [
          (1.0 - @cyan) * one_k,
          (1.0 - @magenta) * one_k,
          (1.0 - @yellow) * one_k,
          @alpha,
         ]
  RGB.new(*rgba)
end