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.



176
177
178
179
180
181
182
183
184
185
186
# File 'lib/cairo/color.rb', line 176

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.



165
166
167
# File 'lib/cairo/color.rb', line 165

def cyan
  @cyan
end

#key_plateObject Also known as: k

Returns the value of attribute key_plate.



165
166
167
# File 'lib/cairo/color.rb', line 165

def key_plate
  @key_plate
end

#magentaObject Also known as: m

Returns the value of attribute magenta.



165
166
167
# File 'lib/cairo/color.rb', line 165

def magenta
  @magenta
end

#yellowObject Also known as: y

Returns the value of attribute yellow.



165
166
167
# File 'lib/cairo/color.rb', line 165

def yellow
  @yellow
end

Instance Method Details

#to_aObject Also known as: to_ary



188
189
190
# File 'lib/cairo/color.rb', line 188

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

#to_cmykObject



204
205
206
# File 'lib/cairo/color.rb', line 204

def to_cmyk
  clone
end

#to_hsvObject



208
209
210
# File 'lib/cairo/color.rb', line 208

def to_hsv
  to_rgb.to_hsv
end

#to_rgbObject



193
194
195
196
197
198
199
200
201
202
# File 'lib/cairo/color.rb', line 193

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