Class: Color::Gray
- Inherits:
-
Base
show all
- Defined in:
- lib/quadtone/color/gray.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
13
14
15
|
# File 'lib/quadtone/color/gray.rb', line 13
def self.cgats_color_rep
'K'
end
|
.cgats_fields ⇒ Object
9
10
11
|
# File 'lib/quadtone/color/gray.rb', line 9
def self.cgats_fields
%w{GRAY_K}
end
|
.component_names ⇒ Object
5
6
7
|
# File 'lib/quadtone/color/gray.rb', line 5
def self.component_names
[:k]
end
|
Instance Method Details
#k ⇒ Object
17
18
19
|
# File 'lib/quadtone/color/gray.rb', line 17
def k
@components[0]
end
|
#to_cgats ⇒ Object
25
26
27
28
29
|
# File 'lib/quadtone/color/gray.rb', line 25
def to_cgats
{
'GRAY_K' => k,
}
end
|
#to_lab ⇒ Object
36
37
38
|
# File 'lib/quadtone/color/gray.rb', line 36
def to_lab
Color::Lab.new(l: 100 - k, a: 0, b: 0)
end
|
#to_rgb ⇒ Object
31
32
33
34
|
# File 'lib/quadtone/color/gray.rb', line 31
def to_rgb
n = 1 - value
Color::RGB.new([n, n, n])
end
|
#to_xyz ⇒ Object
40
41
42
|
# File 'lib/quadtone/color/gray.rb', line 40
def to_xyz
to_lab.to_xyz
end
|
#value ⇒ Object
21
22
23
|
# File 'lib/quadtone/color/gray.rb', line 21
def value
k / 100.0
end
|