Class: Color::CMYK
- Inherits:
-
Base
show all
- Defined in:
- lib/quadtone/color/cmyk.rb
Instance Attribute Summary
Attributes inherited from Base
#components
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#<=>, average, colorspace_name, #eql?, from_cgats, #hash, #initialize, num_components, #to_s, #to_str
Methods included from Math
#deg2rad, #rad2deg
Constructor Details
This class inherits a constructor from Color::Base
Class Method Details
.cgats_color_rep ⇒ Object
14
15
16
|
# File 'lib/quadtone/color/cmyk.rb', line 14
def self.cgats_color_rep
'CMYKcmk1k'
end
|
.cgats_fields ⇒ Object
9
10
11
12
|
# File 'lib/quadtone/color/cmyk.rb', line 9
def self.cgats_fields
%w{CMYKcmk1k_C CMYKcmk1k_M CMYKcmk1k_Y CMYKcmk1k_K
CMYKcmk1k_c CMYKcmk1k_m CMYKcmk1k_k CMYKcmk1k_1k}
end
|
.component_names ⇒ Object
5
6
7
|
# File 'lib/quadtone/color/cmyk.rb', line 5
def self.component_names
[:c, :m, :y, :k, :lc, :lm, :lk, :llk]
end
|
Instance Method Details
#c ⇒ Object
18
19
20
|
# File 'lib/quadtone/color/cmyk.rb', line 18
def c
@components[0]
end
|
#k ⇒ Object
30
31
32
|
# File 'lib/quadtone/color/cmyk.rb', line 30
def k
@components[3]
end
|
#lc ⇒ Object
34
35
36
|
# File 'lib/quadtone/color/cmyk.rb', line 34
def lc
@components[4]
end
|
#lk ⇒ Object
42
43
44
|
# File 'lib/quadtone/color/cmyk.rb', line 42
def lk
@components[6]
end
|
#llk ⇒ Object
46
47
48
|
# File 'lib/quadtone/color/cmyk.rb', line 46
def llk
@components[7]
end
|
#lm ⇒ Object
38
39
40
|
# File 'lib/quadtone/color/cmyk.rb', line 38
def lm
@components[5]
end
|
#m ⇒ Object
22
23
24
|
# File 'lib/quadtone/color/cmyk.rb', line 22
def m
@components[1]
end
|
#to_a ⇒ Object
106
107
108
|
# File 'lib/quadtone/color/cmyk.rb', line 106
def to_a
@components
end
|
#to_cgats ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/quadtone/color/cmyk.rb', line 50
def to_cgats
{
'CMYKcmk1k_C' => c,
'CMYKcmk1k_M' => m,
'CMYKcmk1k_Y' => y,
'CMYKcmk1k_K' => k,
'CMYKcmk1k_c' => lc,
'CMYKcmk1k_m' => lm,
'CMYKcmk1k_k' => lk,
'CMYKcmk1k_1k' => llk,
}
end
|
#to_cmy ⇒ Object
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/quadtone/color/cmyk.rb', line 77
def to_cmy
c0, m0, y0, k0 = *to_cmyk
c0 /= 100.0
m0 /= 100.0
y0 /= 100.0
k0 /= 100.0
c0 = (c0 * (1 - k0)) + k0
m0 = (m0 * (1 - k0)) + k0
y0 = (y0 * (1 - k0)) + k0
Color::CMYK.new([c0 * 100, m0 * 100, y0 * 100])
end
|
#to_cmyk ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/quadtone/color/cmyk.rb', line 63
def to_cmyk
l_factor = 0.5
ll_factor = 0.25
c0 = c + (lc * l_factor)
m0 = m + (lm * l_factor)
y0 = y
k0 = k + (lk * l_factor) + (llk * ll_factor)
Color::CMYK.new([c0, m0, y0, k0])
end
|
#to_lab ⇒ Object
98
99
100
|
# File 'lib/quadtone/color/cmyk.rb', line 98
def to_lab
to_xyz.to_lab
end
|
#to_rgb ⇒ Object
93
94
95
96
|
# File 'lib/quadtone/color/cmyk.rb', line 93
def to_rgb
cmy = to_cmy
Color::RGB.new([1 - (cmy.c / 100), 1 - (cmy.m / 100), 1 - (cmy.y / 100)])
end
|
#to_xyz ⇒ Object
102
103
104
|
# File 'lib/quadtone/color/cmyk.rb', line 102
def to_xyz
to_rgb.to_xyz
end
|
#y ⇒ Object
26
27
28
|
# File 'lib/quadtone/color/cmyk.rb', line 26
def y
@components[2]
end
|