Class: Rszr::Color::CMYA

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

Instance Attribute Summary collapse

Attributes inherited from Base

#alpha

Instance Method Summary collapse

Methods inherited from Base

#==, #cmya, #rgba, #to_fill

Constructor Details

#initialize(cyan, magenta, yellow, alpha = 255) ⇒ CMYA

Returns a new instance of CMYA.



7
8
9
10
11
12
# File 'lib/rszr/color/cmya.rb', line 7

def initialize(cyan, magenta, yellow, alpha = 255)
  if cyan < 0 || cyan > 255 || magenta < 0 || magenta > 255 || yellow < 0 || yellow > 255 || alpha < 0 || alpha > 255
    raise ArgumentError, 'color out of range'
  end
  @cyan, @magenta, @yellow = cyan, magenta, yellow
end

Instance Attribute Details

#cyanObject (readonly)

Returns the value of attribute cyan.



5
6
7
# File 'lib/rszr/color/cmya.rb', line 5

def cyan
  @cyan
end

#magentaObject (readonly)

Returns the value of attribute magenta.



5
6
7
# File 'lib/rszr/color/cmya.rb', line 5

def magenta
  @magenta
end

#yellowObject (readonly)

Returns the value of attribute yellow.



5
6
7
# File 'lib/rszr/color/cmya.rb', line 5

def yellow
  @yellow
end

Instance Method Details

#blueObject



22
23
24
# File 'lib/rszr/color/cmya.rb', line 22

def blue
  255 - yellow
end

#greenObject



18
19
20
# File 'lib/rszr/color/cmya.rb', line 18

def green
  255 - magenta
end

#redObject



14
15
16
# File 'lib/rszr/color/cmya.rb', line 14

def red
  255 - cyan
end