color 1.4.2 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- checksums.yaml.gz.sig +2 -0
- data.tar.gz.sig +2 -3
- data/History.rdoc +33 -0
- data/Manifest.txt +1 -1
- data/README.rdoc +14 -2
- data/Rakefile +20 -5
- data/lib/color.rb +104 -53
- data/lib/color/cmyk.rb +39 -43
- data/lib/color/css.rb +1 -10
- data/lib/color/grayscale.rb +33 -34
- data/lib/color/hsl.rb +96 -65
- data/lib/color/palette/monocontrast.rb +24 -28
- data/lib/color/rgb.rb +152 -67
- data/lib/color/rgb/colors.rb +166 -0
- data/lib/color/rgb/metallic.rb +26 -29
- data/lib/color/yiq.rb +13 -23
- data/test/test_adobecolor.rb +2 -2
- data/test/test_cmyk.rb +2 -2
- data/test/test_color.rb +2 -3
- data/test/test_css.rb +11 -9
- data/test/test_gimp.rb +2 -2
- data/test/test_grayscale.rb +2 -2
- data/test/test_hsl.rb +2 -2
- data/test/test_monocontrast.rb +2 -2
- data/test/test_rgb.rb +38 -4
- data/test/test_yiq.rb +2 -2
- metadata +57 -94
- metadata.gz.sig +0 -0
- data/lib/color/rgb-colors.rb +0 -343
checksums.yaml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
!binary "U0hBMQ==":
|
|
3
|
+
metadata.gz: !binary |-
|
|
4
|
+
YjQwMTIxMzBkMGIzMmI2YmJjOWMwODE3ZDU5ZTlhYTFlNGM2YmQ0Zg==
|
|
5
|
+
data.tar.gz: !binary |-
|
|
6
|
+
M2VjNGUwNmFmOWRhMzQzZjA3OWZhMTM2MDgxYzcxMzc4NjYzOTZlZQ==
|
|
7
|
+
SHA512:
|
|
8
|
+
metadata.gz: !binary |-
|
|
9
|
+
MmYzNTFkZWZjYWM1ZTAxNjJhYzZkMTk0NGE2OTU5MTBiOGM1NWY4Mzg3NDA1
|
|
10
|
+
MmVjMjEzOTYzYzVkMGNkOGRmNDY0MTM0YmI0ZDc3YTYxMDAxMzE1OGZhNTNh
|
|
11
|
+
NmU4Y2Q5ZTY2ZjA1NDMwZThmYTA1ZDNjNTkzZTMzOGEwMzJlYmE=
|
|
12
|
+
data.tar.gz: !binary |-
|
|
13
|
+
NWIxY2I2NTVjN2RjZDQwMTc5NjQwZDRhODM5MmMwODJiMDQwMGNmM2M4Yzk3
|
|
14
|
+
ZDUxMzJhYjE1ODA3ZGY3NTZmMzJkODg0MmNjZTI2NzA5NjcxZjcxNTYzMzk2
|
|
15
|
+
YWQyZGQ3Y2RmY2RkOTc0NzkzMTYxODI1Mzg4MzA5MDA3YjEyYjQ=
|
checksums.yaml.gz.sig
ADDED
data.tar.gz.sig
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
���G�I@�iLDcP��Pÿ���ӣB<Y�®�(���,�;��r_�3��.��
|
|
1
|
+
�L�
|
|
2
|
+
��}��+�n{��`7~�.&J�Q~�$lȊ��V���x{�,��¼���(w^><���\�X�[vBC21��J�7���Δ�w4ļѾJ7a��2\r�u|eò����^o�p�9p��!������)�
|
data/History.rdoc
CHANGED
|
@@ -1,3 +1,36 @@
|
|
|
1
|
+
== 1.5.1 / 2014-01-28
|
|
2
|
+
|
|
3
|
+
* color 1.5 was a yanked release.
|
|
4
|
+
|
|
5
|
+
* Minor enhancements:
|
|
6
|
+
* Added new methods to Color::RGB to make it so that the default defined
|
|
7
|
+
colours can be looked up by hex, name, or both.
|
|
8
|
+
* Added a method to Color::RGB to extract colours from text by hex, name, or
|
|
9
|
+
both.
|
|
10
|
+
* Added new common methods for colour names. Converted colours do not retain
|
|
11
|
+
names.
|
|
12
|
+
* Restructured color comparisons to use protocols instead of custom
|
|
13
|
+
implementations. This makes it easier to implement new colour classes. To
|
|
14
|
+
make this work, color classes should +include+ Color only need to implement
|
|
15
|
+
<tt>#coerce(other)</tt>, <tt>#to_a</tt>, and supported conversion methods
|
|
16
|
+
(e.g., <tt>#to_rgb</tt>).
|
|
17
|
+
* Added @daveheitzman’s initial implementation of an RGB contrast method as
|
|
18
|
+
an extension file: <tt>require 'color/rgb/contrast'</tt>. This method and
|
|
19
|
+
the value it returns should be considered experimental; it requires further
|
|
20
|
+
examination to ensure that the results produced are consistent with the
|
|
21
|
+
contrast comparisons used in Color::Palette::MonoContrast.
|
|
22
|
+
* Reducing duplicated code.
|
|
23
|
+
|
|
24
|
+
* Bug Fixes:
|
|
25
|
+
* Moved +lib/color/rgb-colors.rb+ to +lib/color/rgb/colors.rb+. This should
|
|
26
|
+
have no impact in general.
|
|
27
|
+
* Improved the way that named colors are specified internally.
|
|
28
|
+
* Fixed bugs with Ruby 1.8.7 that may have been introduced in color 1.4.2.
|
|
29
|
+
|
|
30
|
+
* Tooling Changes:
|
|
31
|
+
* Added simplecov for test coverage analysis.
|
|
32
|
+
* Modernized Travis CI support.
|
|
33
|
+
|
|
1
34
|
== 1.4.2 / 2013-06-30
|
|
2
35
|
|
|
3
36
|
Maintenance:
|
data/Manifest.txt
CHANGED
data/README.rdoc
CHANGED
|
@@ -23,8 +23,20 @@ L*a*b*) are not supported because Color does not yet support colour profiles,
|
|
|
23
23
|
giving no meaningful way to convert colours in absolute colour spaces (like
|
|
24
24
|
L*a*b*, XYZ) to non-absolute colour spaces (like RGB).
|
|
25
25
|
|
|
26
|
-
Color version 1.
|
|
27
|
-
|
|
26
|
+
Color version 1.5.1 is mostly a maintenance release, fixing some bugs that may
|
|
27
|
+
have been introduced with the previous release on Ruby 1.8.7. New features
|
|
28
|
+
include an experimental contrast comparison method for RGB colours (found in
|
|
29
|
+
lib/color/rgb/contrast.rb) provided by Dave Heitzman, and methods suggested by
|
|
30
|
+
Thomas Sawyer based on the Spectrum library.
|
|
31
|
+
|
|
32
|
+
Barring bugs introduced in this release, this will be the last version of color
|
|
33
|
+
that supports Ruby 1.8, so make sure that your gem specification is set
|
|
34
|
+
properly, to <tt>~> 1.5</tt> if that matters for your application.
|
|
35
|
+
|
|
36
|
+
=== Note about color 1.5
|
|
37
|
+
|
|
38
|
+
Color 1.5 was released before the documetation was complete and has been
|
|
39
|
+
yanked.
|
|
28
40
|
|
|
29
41
|
== History
|
|
30
42
|
|
data/Rakefile
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
require 'rubygems'
|
|
4
4
|
require 'hoe'
|
|
5
5
|
|
|
6
|
-
Hoe.plugin :bundler
|
|
7
6
|
Hoe.plugin :doofus
|
|
8
7
|
Hoe.plugin :email
|
|
9
8
|
Hoe.plugin :gemspec2
|
|
@@ -12,9 +11,13 @@ Hoe.plugin :minitest
|
|
|
12
11
|
Hoe.plugin :rubyforge
|
|
13
12
|
Hoe.plugin :travis
|
|
14
13
|
|
|
15
|
-
Hoe.spec 'color' do
|
|
16
|
-
developer
|
|
17
|
-
developer
|
|
14
|
+
spec = Hoe.spec 'color' do
|
|
15
|
+
developer('Austin Ziegler', 'austin@rubyforge.org')
|
|
16
|
+
developer('Matt Lyon', 'matt@postsomnia.com')
|
|
17
|
+
|
|
18
|
+
self.need_tar = true
|
|
19
|
+
|
|
20
|
+
# self.require_ruby_version '>= 1.9.2'
|
|
18
21
|
|
|
19
22
|
self.remote_rdoc_dir = '.'
|
|
20
23
|
self.rsync_args << ' --exclude=statsvn/'
|
|
@@ -22,8 +25,8 @@ Hoe.spec 'color' do
|
|
|
22
25
|
self.history_file = 'History.rdoc'
|
|
23
26
|
self.readme_file = 'README.rdoc'
|
|
24
27
|
self.extra_rdoc_files = FileList["*.rdoc"].to_a
|
|
28
|
+
self.licenses = ["MIT"]
|
|
25
29
|
|
|
26
|
-
self.extra_dev_deps << ['hoe-bundler', '~> 1.2']
|
|
27
30
|
self.extra_dev_deps << ['hoe-doofus', '~> 1.0']
|
|
28
31
|
self.extra_dev_deps << ['hoe-gemspec2', '~> 1.1']
|
|
29
32
|
self.extra_dev_deps << ['hoe-git', '~> 1.5']
|
|
@@ -32,3 +35,15 @@ Hoe.spec 'color' do
|
|
|
32
35
|
self.extra_dev_deps << ['minitest', '~> 5.0']
|
|
33
36
|
self.extra_dev_deps << ['rake', '~> 10.0']
|
|
34
37
|
end
|
|
38
|
+
|
|
39
|
+
namespace :test do
|
|
40
|
+
desc "Runs test coverage. Only works Ruby 1.9+ and assumes 'simplecov' is installed."
|
|
41
|
+
task :coverage do
|
|
42
|
+
spec.test_prelude = [
|
|
43
|
+
'require "simplecov"',
|
|
44
|
+
'SimpleCov.start("test_frameworks") { command_name "Minitest" }',
|
|
45
|
+
'gem "minitest"'
|
|
46
|
+
].join('; ')
|
|
47
|
+
Rake::Task['test'].execute
|
|
48
|
+
end
|
|
49
|
+
end
|
data/lib/color.rb
CHANGED
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
|
|
4
4
|
# = Colour Management with Ruby
|
|
5
5
|
module Color
|
|
6
|
-
COLOR_VERSION = '1.
|
|
6
|
+
COLOR_VERSION = '1.5.1'
|
|
7
7
|
|
|
8
8
|
class RGB; end
|
|
9
9
|
class CMYK; end
|
|
10
|
+
class HSL; end
|
|
10
11
|
class GrayScale; end
|
|
11
12
|
class YIQ; end
|
|
12
13
|
|
|
@@ -18,65 +19,115 @@ module Color
|
|
|
18
19
|
# tolerance value of each other.
|
|
19
20
|
COLOR_TOLERANCE = 1e-4
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
# Compares the +other+ colour to this one. The +other+ colour will be
|
|
23
|
+
# coerced to the same type as the current colour. Such converted colour
|
|
24
|
+
# comparisons will always be more approximate than non-converted
|
|
25
|
+
# comparisons.
|
|
26
|
+
#
|
|
27
|
+
# If the +other+ colour cannot be coerced to the current colour class, a
|
|
28
|
+
# +NoMethodError+ exception will be raised.
|
|
29
|
+
#
|
|
30
|
+
# All values are compared as floating-point values, so two colours will be
|
|
31
|
+
# reported equivalent if all component values are within COLOR_TOLERANCE
|
|
32
|
+
# of each other.
|
|
33
|
+
def ==(other)
|
|
34
|
+
Color.equivalent?(self, other)
|
|
35
|
+
end
|
|
26
36
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
end
|
|
37
|
+
# The primary name for the colour.
|
|
38
|
+
def name
|
|
39
|
+
names.first
|
|
40
|
+
end
|
|
32
41
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
42
|
+
# All names for the colour.
|
|
43
|
+
def names
|
|
44
|
+
self.names = nil unless defined? @names
|
|
45
|
+
@names
|
|
46
|
+
end
|
|
47
|
+
def names=(n) # :nodoc:
|
|
48
|
+
@names = Array(n).flatten.compact.map(&:to_s).map(&:downcase).sort.uniq
|
|
49
|
+
end
|
|
50
|
+
alias_method :name=, :names=
|
|
51
|
+
end
|
|
37
52
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
53
|
+
class << Color
|
|
54
|
+
# Returns +true+ if the value is less than COLOR_EPSILON.
|
|
55
|
+
def near_zero?(value)
|
|
56
|
+
(value.abs <= Color::COLOR_EPSILON)
|
|
57
|
+
end
|
|
43
58
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
1.0
|
|
50
|
-
else
|
|
51
|
-
value
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
alias normalize_fractional normalize
|
|
59
|
+
# Returns +true+ if the value is within COLOR_EPSILON of zero or less than
|
|
60
|
+
# zero.
|
|
61
|
+
def near_zero_or_less?(value)
|
|
62
|
+
(value < 0.0 or near_zero?(value))
|
|
63
|
+
end
|
|
55
64
|
|
|
56
|
-
|
|
57
|
-
|
|
65
|
+
# Returns +true+ if the value is within COLOR_EPSILON of one.
|
|
66
|
+
def near_one?(value)
|
|
67
|
+
near_zero?(value - 1.0)
|
|
68
|
+
end
|
|
58
69
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
70
|
+
# Returns +true+ if the value is within COLOR_EPSILON of one or more than
|
|
71
|
+
# one.
|
|
72
|
+
def near_one_or_more?(value)
|
|
73
|
+
(value > 1.0 or near_one?(value))
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Returns +true+ if the two values provided are near each other.
|
|
77
|
+
def near?(x, y)
|
|
78
|
+
(x - y).abs <= Color::COLOR_TOLERANCE
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Returns +true+ if the two colours are roughly equivalent. If colour
|
|
82
|
+
# conversions are required, this all conversions will be implemented
|
|
83
|
+
# using the default conversion mechanism.
|
|
84
|
+
def equivalent?(a, b)
|
|
85
|
+
a.to_a.zip(a.coerce(b).to_a).all? { |(x, y)| near?(x, y) }
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Coerces, if possible, the second given colour object to the first
|
|
89
|
+
# given colour object type. This will probably involve colour
|
|
90
|
+
# conversion and therefore a loss of fidelity.
|
|
91
|
+
def coerce(a, b)
|
|
92
|
+
a.coerce(b)
|
|
93
|
+
end
|
|
67
94
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
95
|
+
# Normalizes the value to the range (0.0) .. (1.0).
|
|
96
|
+
def normalize(value)
|
|
97
|
+
if near_zero_or_less? value
|
|
98
|
+
0.0
|
|
99
|
+
elsif near_one_or_more? value
|
|
100
|
+
1.0
|
|
101
|
+
else
|
|
102
|
+
value
|
|
71
103
|
end
|
|
72
|
-
|
|
104
|
+
end
|
|
105
|
+
alias normalize_fractional normalize
|
|
106
|
+
|
|
107
|
+
# Normalizes the value to the specified range.
|
|
108
|
+
def normalize_to_range(value, range)
|
|
109
|
+
range = (range.end..range.begin) if (range.end < range.begin)
|
|
73
110
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
111
|
+
if value <= range.begin
|
|
112
|
+
range.begin
|
|
113
|
+
elsif value >= range.end
|
|
114
|
+
range.end
|
|
115
|
+
else
|
|
116
|
+
value
|
|
77
117
|
end
|
|
78
|
-
alias normalize_16bit normalize_word
|
|
79
118
|
end
|
|
119
|
+
|
|
120
|
+
# Normalize the value to the range (0) .. (255).
|
|
121
|
+
def normalize_byte(value)
|
|
122
|
+
normalize_to_range(value, 0..255).to_i
|
|
123
|
+
end
|
|
124
|
+
alias normalize_8bit normalize_byte
|
|
125
|
+
|
|
126
|
+
# Normalize the value to the range (0) .. (65535).
|
|
127
|
+
def normalize_word(value)
|
|
128
|
+
normalize_to_range(value, 0..65535).to_i
|
|
129
|
+
end
|
|
130
|
+
alias normalize_16bit normalize_word
|
|
80
131
|
end
|
|
81
132
|
|
|
82
133
|
require 'color/rgb'
|
|
@@ -84,10 +135,10 @@ require 'color/cmyk'
|
|
|
84
135
|
require 'color/grayscale'
|
|
85
136
|
require 'color/hsl'
|
|
86
137
|
require 'color/yiq'
|
|
87
|
-
require 'color/
|
|
138
|
+
require 'color/css'
|
|
88
139
|
|
|
89
|
-
|
|
90
|
-
def
|
|
140
|
+
class << Color
|
|
141
|
+
def const_missing(name) #:nodoc:
|
|
91
142
|
case name
|
|
92
143
|
when "VERSION", :VERSION, "COLOR_TOOLS_VERSION", :COLOR_TOOLS_VERSION
|
|
93
144
|
warn "Color::#{name} has been deprecated. Use Color::COLOR_VERSION instead."
|
|
@@ -113,7 +164,7 @@ module Color
|
|
|
113
164
|
# Color::RGB object will be created.
|
|
114
165
|
# mode = :cmyk:: +values+ must be an array of [ cyan %, magenta %, yellow
|
|
115
166
|
# %, black % ]. A Color::CMYK object will be created.
|
|
116
|
-
def
|
|
167
|
+
def new(values, mode = :rgb)
|
|
117
168
|
warn "Color.new has been deprecated. Use Color::#{mode.to_s.upcase}.new instead."
|
|
118
169
|
color = case mode
|
|
119
170
|
when :hsl
|
data/lib/color/cmyk.rb
CHANGED
|
@@ -3,56 +3,42 @@
|
|
|
3
3
|
# would be mixed from 30% cyan, 0% magenta, 80% yellow, and 30% black.
|
|
4
4
|
# Primarily used in four-colour printing processes.
|
|
5
5
|
class Color::CMYK
|
|
6
|
+
include Color
|
|
7
|
+
|
|
6
8
|
# The format of a DeviceCMYK colour for PDF. In color-tools 2.0 this will
|
|
7
9
|
# be removed from this package and added back as a modification by the
|
|
8
10
|
# PDF::Writer package.
|
|
9
11
|
PDF_FORMAT_STR = "%.3f %.3f %.3f %.3f %s"
|
|
10
12
|
|
|
11
|
-
#
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
# colour's #to_cmyk conversion. If there is no #to_cmyk conversion, this
|
|
15
|
-
# will raise an exception. This will report that two CMYK colours are
|
|
16
|
-
# equivalent if all component values are within COLOR_TOLERANCE of each
|
|
17
|
-
# other.
|
|
18
|
-
def ==(other)
|
|
19
|
-
other = other.to_cmyk
|
|
20
|
-
other.kind_of?(Color::CMYK) and
|
|
21
|
-
((@c - other.c).abs <= Color::COLOR_TOLERANCE) and
|
|
22
|
-
((@m - other.m).abs <= Color::COLOR_TOLERANCE) and
|
|
23
|
-
((@y - other.y).abs <= Color::COLOR_TOLERANCE) and
|
|
24
|
-
((@k - other.k).abs <= Color::COLOR_TOLERANCE)
|
|
13
|
+
# Coerces the other Color object into CMYK.
|
|
14
|
+
def coerce(other)
|
|
15
|
+
other.to_cmyk
|
|
25
16
|
end
|
|
26
17
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
colour.y = y
|
|
35
|
-
colour.k = k
|
|
36
|
-
colour
|
|
37
|
-
end
|
|
18
|
+
class << self
|
|
19
|
+
# Creates a CMYK colour object from fractional values 0..1.
|
|
20
|
+
#
|
|
21
|
+
# Color::CMYK.from_fraction(0.3, 0, 0.8, 0.3)
|
|
22
|
+
def from_fraction(c = 0, m = 0, y = 0, k = 0, &block)
|
|
23
|
+
new(c, m, y, k, 1.0, &block)
|
|
24
|
+
end
|
|
38
25
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
26
|
+
# Creates a CMYK colour object from percentages. Internally, the colour is
|
|
27
|
+
# managed as fractional values 0..1.
|
|
28
|
+
#
|
|
29
|
+
# Color::CMYK.new(30, 0, 80, 30)
|
|
30
|
+
def from_percent(c = 0, m = 0, y = 0, k = 0, &block)
|
|
31
|
+
new(c, m, y, k, &block)
|
|
32
|
+
end
|
|
45
33
|
end
|
|
46
34
|
|
|
47
35
|
# Creates a CMYK colour object from percentages. Internally, the colour is
|
|
48
36
|
# managed as fractional values 0..1.
|
|
49
37
|
#
|
|
50
38
|
# Color::CMYK.new(30, 0, 80, 30)
|
|
51
|
-
def initialize(c = 0, m = 0, y = 0, k = 0)
|
|
52
|
-
@c = c /
|
|
53
|
-
|
|
54
|
-
@y = y / 100.0
|
|
55
|
-
@k = k / 100.0
|
|
39
|
+
def initialize(c = 0, m = 0, y = 0, k = 0, radix = 100.0, &block) # :yields self:
|
|
40
|
+
@c, @m, @y, @k = [ c, m, y, k ].map { |v| Color.normalize(v / radix) }
|
|
41
|
+
block.call(self) if block
|
|
56
42
|
end
|
|
57
43
|
|
|
58
44
|
# Present the colour as a DeviceCMYK fill colour string for PDF. This will
|
|
@@ -138,15 +124,10 @@ class Color::CMYK
|
|
|
138
124
|
# profiles.
|
|
139
125
|
def to_rgb(use_adobe_method = false)
|
|
140
126
|
if use_adobe_method
|
|
141
|
-
|
|
142
|
-
g = 1.0 - [1.0, @m + @k].min
|
|
143
|
-
b = 1.0 - [1.0, @y + @k].min
|
|
127
|
+
Color::RGB.from_fraction(*adobe_cmyk_rgb)
|
|
144
128
|
else
|
|
145
|
-
|
|
146
|
-
g = 1.0 - (@m.to_f * (1.0 - @k.to_f) + @k.to_f)
|
|
147
|
-
b = 1.0 - (@y.to_f * (1.0 - @k.to_f) + @k.to_f)
|
|
129
|
+
Color::RGB.from_fraction(*standard_cmyk_rgb)
|
|
148
130
|
end
|
|
149
|
-
Color::RGB.from_fraction(r, g, b)
|
|
150
131
|
end
|
|
151
132
|
|
|
152
133
|
# Converts the CMYK colour to a single greyscale value. There are
|
|
@@ -264,4 +245,19 @@ class Color::CMYK
|
|
|
264
245
|
def k=(kk)
|
|
265
246
|
@k = Color.normalize(kk)
|
|
266
247
|
end
|
|
248
|
+
|
|
249
|
+
def to_a
|
|
250
|
+
[ c, m, y, k ]
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
private
|
|
254
|
+
# Implements the Adobe PDF conversion of CMYK to RGB.
|
|
255
|
+
def adobe_cmyk_rgb
|
|
256
|
+
[ @c, @m, @y ].map { |v| 1.0 - [ 1.0, v + @k ].min }
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
# Implements the standard conversion of CMYK to RGB.
|
|
260
|
+
def standard_cmyk_rgb
|
|
261
|
+
[ @c, @m, @y ].map { |v| 1.0 - (v * (1.0 - k) + k) }
|
|
262
|
+
end
|
|
267
263
|
end
|