spectrum 0.0.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.
@@ -0,0 +1,93 @@
1
+ == Color 1.4.1 / 2010.02.03
2
+ * Imported to github.
3
+ * Converted to Hoe 2.5 spec format.
4
+
5
+ == Color 1.4.0 / 2007.02.11
6
+ * Merged Austin Ziegler's color-tools library (previously part of the Ruby
7
+ PDF Tools project) with Matt Lyon's color library.
8
+ - The HSL implementation from the Color class has been merged into
9
+ Color::HSL. Color is a module the way it was for color-tools.
10
+ - A thin veneer has been written to allow Color::new to return a Color::HSL
11
+ instance; Color::HSL supports as many methods as possible that were
12
+ previously supported by the Color class.
13
+ - Values that were previously rounded by Color are no longer rounded;
14
+ fractional values matter.
15
+ * Converted to hoe for project management.
16
+ * Moved to the next step of deprecating Color::Name values; printing a
17
+ warning for each use (see the history for color-tools 1.3.0).
18
+ * Print a warning on the access of either VERSION or COLOR_TOOLS_VERSION; the
19
+ version constant is now COLOR_VERSION.
20
+ * Added humanized versions of accessors (e.g., CMYK colours now have both #cyan
21
+ and #c to access the cyan component of the colour; #cyan provides the value
22
+ as a percentage).
23
+ * Added CSS3 formatters for RGB, RGBA, HSL, and HSLA outputs. Note that the
24
+ Color library does not yet have a way of setting alpha opacity, so the
25
+ output for RGBA and HSLA are at full alpha opacity (1.0). The values are
26
+ output with two decimal places.
27
+ * Applied a patch to provide simple arithmetic colour addition and subtraction
28
+ to Color::GrayScale and Color::RGB. The patch was contributed by Jeremy
29
+ Hinegardner <jeremy@hinegardner.org>. This patch also provides the ability to
30
+ return the maximum RGB value as a grayscale colour.
31
+ * Fixed two problems reported by Jean Krohn <jb.krohn@free.fr> against
32
+ color-tools relating to RGB-to-HSL and HSL-to-RGB conversion. (Color and
33
+ color-tools use the same formulas, but the ordering of the calculations is
34
+ slightly different with Color and did not suffer from this problem;
35
+ color-tools was more sensitive to floating-point values and precision
36
+ errors.)
37
+ * Fixed an issue with HSL/RGB conversions reported by Adam Johnson
38
+ <adam.sven.johnson@gmail.com>.
39
+ * Added an Adobe Color swatch (Photoshop) palette reader,
40
+ Color::Palette::AdobeColor (for .aco files only).
41
+
42
+ == Color 0.1.0 / 2006.08.05
43
+ * Added HSL (degree, percent, percent) interface.
44
+ * Removed RGB instance variable; color is managed internally as HSL floating
45
+ point.
46
+ * Tests!
47
+
48
+ == color-tools 1.3.0
49
+ * Added new metallic colours suggested by Jim Freeze <jfn@freeze.org>. These
50
+ are in the namespace Color::Metallic.
51
+ * Colours that were defined in the Color namespace (e.g., Color::Red,
52
+ Color::AliceBlue) are now defined in Color::RGB (e.g., Color::RGB::Red,
53
+ Color::RGB::AliceBlue). They are added back to the Color namespace on the
54
+ first use of the old colours and a warning is printed. In version 1.4, this
55
+ warning will be printed on every use of the old colours. In version 1.5,
56
+ the backwards compatible support for colours like Color::Red will be
57
+ removed completely.
58
+ * Added the Color::CSS module, color/css or Color::CSS that provides a name
59
+ lookup of Color::RGB-namespaced constants with Color::CSS[name]. Most of
60
+ these colours (which are mirrored from the Color::RGB default colours) are
61
+ only "officially" recognised under the CSS3 colour module or SVG.
62
+ * Added the Color::HSL colour space and some helper utilities to Color::RGB
63
+ for colour manipulation using the HSL value.
64
+ * Controlled internal value replacement to be between 0 and 1 for all
65
+ colours.
66
+ * Updated Color::Palette::Gimp to more meaningfully deal with duplicate named
67
+ colours. Named colours now return an array of colours.
68
+ * Indicated the plans for some methods and constants out to color-tools 2.0.
69
+ * Added unit tests and fixed a number of hidden bugs because of them.
70
+
71
+ == color-tools 1.2.0
72
+ * Changed installer from a custom-written install.rb to setup.rb
73
+ 3.3.1-modified.
74
+ * Added Color::GreyScale (or Color::GrayScale).
75
+ * Added Color::YIQ. This colour definition is incomplete; it does not have
76
+ conversions from YIQ to other colour spaces.
77
+
78
+ == color-tools 1.1.0
79
+ * Added color/palette/gimp to support the reading and use of GIMP color
80
+ palettes.
81
+
82
+ == color-tools 1.0.0
83
+ * Initial release.
84
+
85
+ == Copyright
86
+ Color
87
+ Colour Management with Ruby
88
+ http://rubyforge.org/projects/color
89
+
90
+ Licensed under a MIT-style licence. See Licence.txt in the main
91
+ distribution for full licensing information.
92
+
93
+ Copyright (c) 2005 - 2010 Austin Ziegler and Matt Lyon
@@ -0,0 +1,18 @@
1
+ == Installing Color
2
+
3
+ Color may be installed with:
4
+
5
+ % ruby setup.rb
6
+
7
+ Alternatively, the RubyGems version of Color may be installed from the usual
8
+ sources.
9
+
10
+ == Copyright
11
+ Color
12
+ Colour Management with Ruby
13
+ http://rubyforge.org/projects/color
14
+
15
+ Licensed under a MIT-style licence. See Licence.txt in the main
16
+ distribution for full licensing information.
17
+
18
+ Copyright (c) 2005 - 2010 Austin Ziegler and Matt Lyon
@@ -0,0 +1,27 @@
1
+ Color
2
+ Colour management in Ruby
3
+ http://rubyforge.org/projects/color/
4
+
5
+ Copyright (c) 2005 - 2010 Austin Ziegler, Matt Lyon, and other contributors
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
8
+ this software and associated documentation files (the "Software"), to deal in
9
+ the Software without restriction, including without limitation the rights to
10
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
11
+ of the Software, and to permit persons to whom the Software is furnished to do
12
+ so, subject to the following conditions:
13
+
14
+ * The names of its contributors may not be used to endorse or promote
15
+ products derived from this software without specific prior written
16
+ permission.
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
@@ -0,0 +1,35 @@
1
+ = Spectrun
2
+
3
+ Spectrum is a fork of the Color library.
4
+
5
+ Color is a Ruby library to provide basic RGB, CMYK, HSL, and other colourspace
6
+ manipulation support to applications that require it. It also provides 152
7
+ named RGB colours (184 with spelling variations) that are commonly supported
8
+ in HTML, SVG, and X11 applications. A technique for generating monochromatic
9
+ contrasting palettes is also included.
10
+
11
+ The capabilities of the Color library are limited to pure mathematical
12
+ manipulation of the colours based on colour theory without reference to colour
13
+ profiles (such as sRGB or Adobe RGB). For most purposes, when working with the
14
+ RGB and HSL colours, this won't matter. However, some colour models (like CIE
15
+ L*a*b*) are not supported because Color does not yet support colour profiles,
16
+ giving no meaningful way to convert colours in absolute colour spaces (like
17
+ L*a*b*, XYZ) to non-absolute colour spaces (like RGB).
18
+
19
+ Color version 1.4 is the result of a project merge between color.rb 0.1.0 by
20
+ Matt Lyon and color-tools 1.3 by Austin Ziegler. Please see History.txt for
21
+ details on the changes this merge brings. Color version 1.4.1 changes
22
+ development to GitHub and fixes some small problems.
23
+
24
+ Copyright:: Copyright (c) 2005 - 2010 by Austin Ziegler and Matt Lyon
25
+ Version:: 1.4.1
26
+ Homepage:: http://rubyforge.org/projects/color/
27
+ Licence:: MIT-Style; see Licence.txt
28
+
29
+ Color::Palette was developed based on techniques described by Andy "Malarkey"
30
+ Clarke[1], implemented in JavaScript by Steve G. Chipman at SlayerOffice[2] and
31
+ by Patrick Fitzgerald of BarelyFitz[3] in PHP.
32
+
33
+ [1] http://www.stuffandnonsense.co.uk/archives/creating_colour_palettes.html
34
+ [2] http://slayeroffice.com/tools/color_palette/
35
+ [3] http://www.barelyfitz.com/projects/csscolor/
@@ -0,0 +1,145 @@
1
+ # :title: Color -- Colour Management with Ruby
2
+ # :main: README.txt
3
+
4
+ #--
5
+ # Color
6
+ # Colour management with Ruby
7
+ # http://rubyforge.org/projects/color
8
+ # Version 1.4.1
9
+ #
10
+ # Licensed under a MIT-style licence. See Licence.txt in the main
11
+ # distribution for full licensing information.
12
+ #
13
+ # Copyright (c) 2005 - 2010 Austin Ziegler and Matt Lyon
14
+ #++
15
+
16
+ # = Colour Management with Ruby
17
+ module Spectrum
18
+ COLOR_VERSION = '1.4.1'
19
+
20
+ class RGB; end
21
+ class CMYK; end
22
+ class GrayScale; end
23
+ class YIQ; end
24
+
25
+ # The maximum "resolution" for colour math; if any value is less than or
26
+ # equal to this value, it is treated as zero.
27
+ COLOR_EPSILON = 1e-5
28
+ # The tolerance for comparing the components of two colours. In general,
29
+ # colours are considered equal if all of their components are within this
30
+ # tolerance value of each other.
31
+ COLOR_TOLERANCE = 1e-4
32
+
33
+ class << self
34
+ # Returns +true+ if the value is less than COLOR_EPSILON.
35
+ def near_zero?(value)
36
+ (value.abs <= COLOR_EPSILON)
37
+ end
38
+
39
+ # Returns +true+ if the value is within COLOR_EPSILON of zero or less than
40
+ # zero.
41
+ def near_zero_or_less?(value)
42
+ (value < 0.0 or near_zero?(value))
43
+ end
44
+
45
+ # Returns +true+ if the value is within COLOR_EPSILON of one.
46
+ def near_one?(value)
47
+ near_zero?(value - 1.0)
48
+ end
49
+
50
+ # Returns +true+ if the value is within COLOR_EPSILON of one or more than
51
+ # one.
52
+ def near_one_or_more?(value)
53
+ (value > 1.0 or near_one?(value))
54
+ end
55
+
56
+ # Normalizes the value to the range (0.0) .. (1.0).
57
+ def normalize(value)
58
+ if near_zero_or_less? value
59
+ 0.0
60
+ elsif near_one_or_more? value
61
+ 1.0
62
+ else
63
+ value
64
+ end
65
+ end
66
+ alias normalize_fractional normalize
67
+
68
+ def normalize_to_range(value, range)
69
+ range = (range.end..range.begin) if (range.end < range.begin)
70
+
71
+ if value <= range.begin
72
+ range.begin
73
+ elsif value >= range.end
74
+ range.end
75
+ else
76
+ value
77
+ end
78
+ end
79
+
80
+ # Normalize the value to the range (0) .. (255).
81
+ def normalize_byte(value)
82
+ normalize_to_range(value, 0..255).to_i
83
+ end
84
+ alias normalize_8bit normalize_byte
85
+
86
+ # Normalize the value to the range (0) .. (65535).
87
+ def normalize_word(value)
88
+ normalize_to_range(value, 0..65535).to_i
89
+ end
90
+ alias normalize_16bit normalize_word
91
+ end
92
+ end
93
+
94
+ require 'spectrum/rgb'
95
+ require 'spectrum/cmyk'
96
+ require 'spectrum/grayscale'
97
+ require 'spectrum/hsl'
98
+ require 'spectrum/yiq'
99
+ require 'spectrum/rgb/metallic'
100
+
101
+ module Color
102
+ def self.const_missing(name) #:nodoc:
103
+ case name
104
+ when "VERSION", :VERSION, "COLOR_TOOLS_VERSION", :COLOR_TOOLS_VERSION
105
+ warn "Spectrum::#{name} has been deprecated. Use Spectrum::COLOR_VERSION instead."
106
+ Spectrum::COLOR_VERSION
107
+ else
108
+ if Spectrum::RGB.const_defined?(name)
109
+ warn "Spectrum::#{name} has been deprecated. Use Spectrum::RGB::#{name} instead."
110
+ Spectrum::RGB.const_get(name)
111
+ else
112
+ super
113
+ end
114
+ end
115
+ end
116
+
117
+ # Provides a thin veneer over the Color module to make it seem like this
118
+ # is Color 0.1.0 (a class) and not Color 1.4.1 (a module). This
119
+ # "constructor" will be removed in the future.
120
+ #
121
+ # mode = :hsl:: +values+ must be an array of [ hue deg, sat %, lum % ].
122
+ # A Spectrum::HSL object will be created.
123
+ # mode = :rgb:: +values+ will either be an HTML-style colour string or
124
+ # an array of [ red, green, blue ] (range 0 .. 255). A
125
+ # Spectrum::RGB object will be created.
126
+ # mode = :cmyk:: +values+ must be an array of [ cyan %, magenta %, yellow
127
+ # %, black % ]. A Spectrum::CMYK object will be created.
128
+ def self.new(values, mode = :rgb)
129
+ warn "Color.new has been deprecated. Use Spectrum::#{mode.to_s.upcase}.new instead."
130
+ color = case mode
131
+ when :hsl
132
+ Spectrum::HSL.new(*values)
133
+ when :rgb
134
+ values = [ values ].flatten
135
+ if values.size == 1
136
+ Spectrum::RGB.from_html(*values)
137
+ else
138
+ Spectrum::RGB.new(*values)
139
+ end
140
+ when :cmyk
141
+ Spectrum::CMYK.new(*values)
142
+ end
143
+ color.to_hsl
144
+ end
145
+ end
@@ -0,0 +1,281 @@
1
+ #--
2
+ # Spectrum
3
+ #
4
+ # Based on Color
5
+ # Colour management with Ruby
6
+ # http://rubyforge.org/projects/color
7
+ # Version 1.4.1
8
+ #
9
+ # Licensed under a MIT-style licence. See Licence.txt in the main
10
+ # distribution for full licensing information.
11
+ #
12
+ # Copyright (c) 2005 - 2010 Austin Ziegler and Matt Lyon
13
+ #++
14
+
15
+ # An CMYK colour object. CMYK (cyan, magenta, yellow, and black) colours are
16
+ # based on additive percentages of ink. A CMYK colour of (0.3, 0, 0.8, 0.3)
17
+ # would be mixed from 30% cyan, 0% magenta, 80% yellow, and 30% black.
18
+ # Primarily used in four-colour printing processes.
19
+ class Spectrum::CMYK
20
+ # The format of a DeviceCMYK colour for PDF. In color-tools 2.0 this will
21
+ # be removed from this package and added back as a modification by the
22
+ # PDF::Writer package.
23
+ PDF_FORMAT_STR = "%.3f %.3f %.3f %.3f %s"
24
+
25
+ # Compares the other colour to this one. The other colour will be
26
+ # converted to CMYK before comparison, so the comparison between a CMYK
27
+ # colour and a non-CMYK colour will be approximate and based on the other
28
+ # colour's #to_cmyk conversion. If there is no #to_cmyk conversion, this
29
+ # will raise an exception. This will report that two CMYK colours are
30
+ # equivalent if all component values are within COLOR_TOLERANCE of each
31
+ # other.
32
+ def ==(other)
33
+ other = other.to_cmyk
34
+ other.kind_of?(Spectrum::CMYK) and
35
+ ((@c - other.c).abs <= Spectrum::COLOR_TOLERANCE) and
36
+ ((@m - other.m).abs <= Spectrum::COLOR_TOLERANCE) and
37
+ ((@y - other.y).abs <= Spectrum::COLOR_TOLERANCE) and
38
+ ((@k - other.k).abs <= Spectrum::COLOR_TOLERANCE)
39
+ end
40
+
41
+ # Creates a CMYK colour object from fractional values 0..1.
42
+ #
43
+ # Spectrum::CMYK.from_fraction(0.3, 0, 0.8, 0.3)
44
+ def self.from_fraction(c = 0, m = 0, y = 0, k = 0)
45
+ colour = Spectrum::CMYK.new
46
+ colour.c = c
47
+ colour.m = m
48
+ colour.y = y
49
+ colour.k = k
50
+ colour
51
+ end
52
+
53
+ # Creates a CMYK colour object from percentages. Internally, the colour is
54
+ # managed as fractional values 0..1.
55
+ #
56
+ # Spectrum::CMYK.new(30, 0, 80, 30)
57
+ def self.from_percent(c = 0, m = 0, y = 0, k = 0)
58
+ Spectrum::CMYK.new(c, m, y, k)
59
+ end
60
+
61
+ # Creates a CMYK colour object from percentages. Internally, the colour is
62
+ # managed as fractional values 0..1.
63
+ #
64
+ # Spectrum::CMYK.new(30, 0, 80, 30)
65
+ def initialize(c = 0, m = 0, y = 0, k = 0)
66
+ @c = c / 100.0
67
+ @m = m / 100.0
68
+ @y = y / 100.0
69
+ @k = k / 100.0
70
+ end
71
+
72
+ # Present the colour as a DeviceCMYK fill colour string for PDF. This will
73
+ # be removed from the default package in color-tools 2.0.
74
+ def pdf_fill
75
+ PDF_FORMAT_STR % [ @c, @m, @y, @k, "k" ]
76
+ end
77
+
78
+ # Present the colour as a DeviceCMYK stroke colour string for PDF. This
79
+ # will be removed from the default package in color-tools 2.0.
80
+ def pdf_stroke
81
+ PDF_FORMAT_STR % [ @c, @m, @y, @k, "K" ]
82
+ end
83
+
84
+ # Present the colour as an RGB HTML/CSS colour string (e.g., "#aabbcc").
85
+ # Note that this will perform a #to_rgb operation using the default
86
+ # conversion formula.
87
+ def html
88
+ to_rgb.html
89
+ end
90
+
91
+ # Present the colour as an RGB HTML/CSS colour string (e.g., "rgb(0%, 50%,
92
+ # 100%)"). Note that this will perform a #to_rgb operation using the
93
+ # default conversion formula.
94
+ def css_rgb
95
+ to_rgb.css_rgb
96
+ end
97
+
98
+ # Present the colour as an RGBA (with alpha) HTML/CSS colour string (e.g.,
99
+ # "rgb(0%, 50%, 100%, 1)"). Note that this will perform a #to_rgb
100
+ # operation using the default conversion formula.
101
+ def css_rgba
102
+ to_rgb.css_rgba
103
+ end
104
+
105
+ # Present the colour as an HSL HTML/CSS colour string (e.g., "hsl(180,
106
+ # 25%, 35%)"). Note that this will perform a #to_hsl operation using the
107
+ # default conversion formula.
108
+ def css_hsl
109
+ to_hsl.css_hsl
110
+ end
111
+
112
+ # Present the colour as an HSLA (with alpha) HTML/CSS colour string (e.g.,
113
+ # "hsla(180, 25%, 35%, 1)"). Note that this will perform a #to_hsl
114
+ # operation using the default conversion formula.
115
+ def css_hsla
116
+ to_hsl.css_hsla
117
+ end
118
+
119
+ # Converts the CMYK colour to RGB. Most colour experts strongly suggest
120
+ # that this is not a good idea (some even suggesting that it's a very bad
121
+ # idea). CMYK represents additive percentages of inks on white paper,
122
+ # whereas RGB represents mixed colour intensities on a black screen.
123
+ #
124
+ # However, the colour conversion can be done, and there are two different
125
+ # methods for the conversion that provide slightly different results.
126
+ # Adobe PDF conversions are done with the first form.
127
+ #
128
+ # # Adobe PDF Display Formula
129
+ # r = 1.0 - min(1.0, c + k)
130
+ # g = 1.0 - min(1.0, m + k)
131
+ # b = 1.0 - min(1.0, y + k)
132
+ #
133
+ # # Other
134
+ # r = 1.0 - (c * (1.0 - k) + k)
135
+ # g = 1.0 - (m * (1.0 - k) + k)
136
+ # b = 1.0 - (y * (1.0 - k) + k)
137
+ #
138
+ # If we have a CMYK colour of [33% 66% 83% 25%], the first method will
139
+ # give an approximate RGB colour of (107, 23, 0) or #6b1700. The second
140
+ # method will give an approximate RGB colour of (128, 65, 33) or #804121.
141
+ # Which is correct? Although the colours may seem to be drastically
142
+ # different in the RGB colour space, they are very similar colours,
143
+ # differing mostly in intensity. The first is a darker, slightly redder
144
+ # brown; the second is a lighter brown.
145
+ #
146
+ # Because of this subtlety, both methods are now offered for conversion.
147
+ # The Adobe method is not used by default; to enable it, pass +true+ to
148
+ # #to_rgb.
149
+ #
150
+ # Future versions of Spectrum may offer other conversion mechanisms that
151
+ # offer greater colour fidelity, including recognition of ICC colour
152
+ # profiles.
153
+ def to_rgb(use_adobe_method = false)
154
+ if use_adobe_method
155
+ r = 1.0 - [1.0, @c + @k].min
156
+ g = 1.0 - [1.0, @m + @k].min
157
+ b = 1.0 - [1.0, @y + @k].min
158
+ else
159
+ r = 1.0 - (@c.to_f * (1.0 - @k.to_f) + @k.to_f)
160
+ g = 1.0 - (@m.to_f * (1.0 - @k.to_f) + @k.to_f)
161
+ b = 1.0 - (@y.to_f * (1.0 - @k.to_f) + @k.to_f)
162
+ end
163
+ Spectrum::RGB.from_fraction(r, g, b)
164
+ end
165
+
166
+ # Converts the CMYK colour to a single greyscale value. There are
167
+ # undoubtedly multiple methods for this conversion, but only a minor
168
+ # variant of the Adobe conversion method will be used:
169
+ #
170
+ # g = 1.0 - min(1.0, 0.299 * c + 0.587 * m + 0.114 * y + k)
171
+ #
172
+ # This treats the CMY values similarly to YIQ (NTSC) values and then adds
173
+ # the level of black. This is a variant of the Adobe version because it
174
+ # uses the more precise YIQ (NTSC) conversion values for Y (intensity)
175
+ # rather than the approximates provided by Adobe (0.3, 0.59, and 0.11).
176
+ def to_grayscale
177
+ c = 0.299 * @c.to_f
178
+ m = 0.587 * @m.to_f
179
+ y = 0.114 * @y.to_f
180
+ g = 1.0 - [1.0, c + m + y + @k].min
181
+ Spectrum::GrayScale.from_fraction(g)
182
+ end
183
+ alias to_greyscale to_grayscale
184
+
185
+ def to_cmyk
186
+ self
187
+ end
188
+
189
+ def inspect
190
+ "CMYK [%.2f%%, %.2f%%, %.2f%%, %.2f%%]" % [ cyan, magenta, yellow, black ]
191
+ end
192
+
193
+ # Converts to RGB then YIQ.
194
+ def to_yiq
195
+ to_rgb.to_yiq
196
+ end
197
+
198
+ # Converts to RGB then HSL.
199
+ def to_hsl
200
+ to_rgb.to_hsl
201
+ end
202
+
203
+ # Returns the cyan (C) component of the CMYK colour as a percentage value.
204
+ def cyan
205
+ @c * 100.0
206
+ end
207
+ # Returns the cyan (C) component of the CMYK colour as a value in the
208
+ # range 0.0 .. 1.0.
209
+ def c
210
+ @c
211
+ end
212
+ # Sets the cyan (C) component of the CMYK colour as a percentage value.
213
+ def cyan=(cc)
214
+ @c = Spectrum.normalize(cc / 100.0)
215
+ end
216
+ # Sets the cyan (C) component of the CMYK colour as a value in the range
217
+ # 0.0 .. 1.0.
218
+ def c=(cc)
219
+ @c = Spectrum.normalize(cc)
220
+ end
221
+
222
+ # Returns the magenta (M) component of the CMYK colour as a percentage
223
+ # value.
224
+ def magenta
225
+ @m * 100.0
226
+ end
227
+ # Returns the magenta (M) component of the CMYK colour as a value in the
228
+ # range 0.0 .. 1.0.
229
+ def m
230
+ @m
231
+ end
232
+ # Sets the magenta (M) component of the CMYK colour as a percentage value.
233
+ def magenta=(mm)
234
+ @m = Spectrum.normalize(mm / 100.0)
235
+ end
236
+ # Sets the magenta (M) component of the CMYK colour as a value in the
237
+ # range 0.0 .. 1.0.
238
+ def m=(mm)
239
+ @m = Spectrum.normalize(mm)
240
+ end
241
+
242
+ # Returns the yellow (Y) component of the CMYK colour as a percentage
243
+ # value.
244
+ def yellow
245
+ @y * 100.0
246
+ end
247
+ # Returns the yellow (Y) component of the CMYK colour as a value in the
248
+ # range 0.0 .. 1.0.
249
+ def y
250
+ @y
251
+ end
252
+ # Sets the yellow (Y) component of the CMYK colour as a percentage value.
253
+ def yellow=(yy)
254
+ @y = Spectrum.normalize(yy / 100.0)
255
+ end
256
+ # Sets the yellow (Y) component of the CMYK colour as a value in the range
257
+ # 0.0 .. 1.0.
258
+ def y=(kk)
259
+ @y = Spectrum.normalize(kk)
260
+ end
261
+
262
+ # Returns the black (K) component of the CMYK colour as a percentage
263
+ # value.
264
+ def black
265
+ @k * 100.0
266
+ end
267
+ # Returns the black (K) component of the CMYK colour as a value in the
268
+ # range 0.0 .. 1.0.
269
+ def k
270
+ @k
271
+ end
272
+ # Sets the black (K) component of the CMYK colour as a percentage value.
273
+ def black=(kk)
274
+ @k = Spectrum.normalize(kk / 100.0)
275
+ end
276
+ # Sets the black (K) component of the CMYK colour as a value in the range
277
+ # 0.0 .. 1.0.
278
+ def k=(kk)
279
+ @k = Spectrum.normalize(kk)
280
+ end
281
+ end