Class: DynamicPDFApi::CmykColor

Inherits:
Color
  • Object
show all
Defined in:
lib/ruby_client/CmykColor.rb

Overview

Represents a CMYK color.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cyan = 0, magenta = 0, yellow = 0, black = 0) ⇒ CmykColor

Initializes a new instance of the CmykColor class.

Values must be between 0.0 and 1.0.

Parameters:

  • cyan (float) (defaults to: 0)

    The cyan intensity.

  • magenta (float) (defaults to: 0)

    The magenta intensity.

  • yellow (float) (defaults to: 0)

    The yellow intensity.

  • black (float) (defaults to: 0)

    The black intensity.



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ruby_client/CmykColor.rb', line 18

def initialize(cyan = 0, magenta = 0, yellow = 0, black = 0)
  super()
  if cyan < 0.0 || cyan > 1.0 || magenta < 0.0 || magenta > 1.0 || yellow < 0.0 || yellow > 1.0 || black < 0.0 || black > 1.0
    raise 'CMYK values must be from 0.0 to 1.0.'
  end

  @_color_string = "cmyk(#{cyan},#{magenta},#{yellow},#{black})"
  @cyan = cyan
  @magenta = magenta
  @yellow = yellow
  @black = black
end

Instance Attribute Details

#_color_stringObject

Returns the value of attribute _color_string.



45
46
47
# File 'lib/ruby_client/CmykColor.rb', line 45

def _color_string
  @_color_string
end

Instance Method Details

#blackObject

Gets the color black.



34
35
36
# File 'lib/ruby_client/CmykColor.rb', line 34

def black
  CmykColor.new(1, 1, 1, 1)
end

#whiteObject

Gets the color white.



41
42
43
# File 'lib/ruby_client/CmykColor.rb', line 41

def white
  CmykColor.new(0, 0, 0, 0)
end