spectrum 0.0.1 → 0.2.0

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.
Files changed (48) hide show
  1. checksums.yaml +7 -0
  2. data/HISTORY.md +56 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +255 -0
  5. data/lib/spectrum/describe.rb +55 -0
  6. data/lib/spectrum/feature/advice.rb +31 -0
  7. data/lib/spectrum/feature/feature.rb +192 -0
  8. data/lib/spectrum/feature/featurette.rb +68 -0
  9. data/lib/spectrum/feature/scenario.rb +203 -0
  10. data/lib/spectrum/feature/step.rb +50 -0
  11. data/lib/spectrum/feature.rb +45 -0
  12. data/lib/spectrum/spec/context.rb +409 -0
  13. data/lib/spectrum/spec/example.rb +231 -0
  14. data/lib/spectrum/spec/hooks.rb +83 -0
  15. data/lib/spectrum/testcase/test_case.rb +328 -0
  16. data/lib/spectrum/testcase/test_proc.rb +143 -0
  17. data/lib/spectrum/testcase.rb +28 -0
  18. data/lib/spectrum/version.rb +3 -0
  19. data/lib/spectrum/world.rb +15 -0
  20. data/lib/spectrum.rb +14 -138
  21. metadata +71 -72
  22. data/History.txt +0 -93
  23. data/Install.txt +0 -18
  24. data/Licence.txt +0 -27
  25. data/README.txt +0 -35
  26. data/lib/spectrum/cmyk.rb +0 -281
  27. data/lib/spectrum/css.rb +0 -28
  28. data/lib/spectrum/grayscale.rb +0 -212
  29. data/lib/spectrum/hsl.rb +0 -221
  30. data/lib/spectrum/palette/adobecolor.rb +0 -272
  31. data/lib/spectrum/palette/gimp.rb +0 -116
  32. data/lib/spectrum/palette/monocontrast.rb +0 -180
  33. data/lib/spectrum/palette.rb +0 -16
  34. data/lib/spectrum/rgb/metallic.rb +0 -43
  35. data/lib/spectrum/rgb-colors.rb +0 -355
  36. data/lib/spectrum/rgb.rb +0 -453
  37. data/lib/spectrum/yiq.rb +0 -84
  38. data/test/test_adobecolor.rb +0 -419
  39. data/test/test_all.rb +0 -23
  40. data/test/test_cmyk.rb +0 -128
  41. data/test/test_color.rb +0 -141
  42. data/test/test_css.rb +0 -29
  43. data/test/test_gimp.rb +0 -101
  44. data/test/test_grayscale.rb +0 -121
  45. data/test/test_hsl.rb +0 -153
  46. data/test/test_monocontrast.rb +0 -142
  47. data/test/test_rgb.rb +0 -344
  48. data/test/test_yiq.rb +0 -73
data/README.txt DELETED
@@ -1,35 +0,0 @@
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/
data/lib/spectrum/cmyk.rb DELETED
@@ -1,281 +0,0 @@
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
data/lib/spectrum/css.rb DELETED
@@ -1,28 +0,0 @@
1
- #--
2
- # Spectrum
3
- # Colour management with Ruby
4
- # http://rubyforge.org/projects/color
5
- # Version 1.4.1
6
- #
7
- # Licensed under a MIT-style licence. See Licence.txt in the main
8
- # distribution for full licensing information.
9
- #
10
- # Copyright (c) 2005 - 2010 Austin Ziegler and Matt Lyon
11
- #++
12
-
13
- require 'color'
14
-
15
- # This namespace contains some CSS colour names.
16
- module Spectrum::CSS
17
- # Returns the RGB colour for name or +nil+ if the name is not valid.
18
- def self.[](name)
19
- @colors[name.to_s.downcase.to_sym]
20
- end
21
-
22
- @colors = {}
23
- Spectrum::RGB.constants.each do |const|
24
- next if const == "PDF_FORMAT_STR"
25
- next if const == "Metallic"
26
- @colors[const.downcase.to_sym] ||= Spectrum::RGB.const_get(const)
27
- end
28
- end
@@ -1,212 +0,0 @@
1
- #--
2
- # Color
3
- # Colour management with Ruby
4
- # http://rubyforge.org/projects/color
5
- # Version 1.4.1
6
- #
7
- # Licensed under a MIT-style licence. See Licence.txt in the main
8
- # distribution for full licensing information.
9
- #
10
- # Copyright (c) 2005 - 2010 Austin Ziegler and Matt Lyon
11
- #++
12
-
13
- # A colour object representing shades of grey. Used primarily in PDF
14
- # document creation.
15
- class Spectrum::GrayScale
16
- # The format of a DeviceGrey colour for PDF. In color-tools 2.0 this will
17
- # be removed from this package and added back as a modification by the
18
- # PDF::Writer package.
19
- PDF_FORMAT_STR = "%.3f %s"
20
-
21
- # Creates a greyscale colour object from fractional values 0..1.
22
- #
23
- # Spectrum::GreyScale.from_fraction(0.5)
24
- def self.from_fraction(g = 0)
25
- color = Spectrum::GrayScale.new
26
- color.g = g
27
- color
28
- end
29
-
30
- # Creates a greyscale colour object from percentages 0..100.
31
- #
32
- # Spectrum::GrayScale.from_percent(50)
33
- def self.from_percent(g = 0)
34
- Spectrum::GrayScale.new(g)
35
- end
36
-
37
- # Creates a greyscale colour object from percentages 0..100.
38
- #
39
- # Spectrum::GrayScale.new(50)
40
- def initialize(g = 0)
41
- @g = g / 100.0
42
- end
43
-
44
- # Compares the other colour to this one. The other colour will be
45
- # converted to GreyScale before comparison, so the comparison between a
46
- # GreyScale colour and a non-GreyScale colour will be approximate and
47
- # based on the other colour's #to_greyscale conversion. If there is no
48
- # #to_greyscale conversion, this will raise an exception. This will report
49
- # that two GreyScale values are equivalent if they are within
50
- # COLOR_TOLERANCE of each other.
51
- def ==(other)
52
- other = other.to_grayscale
53
- other.kind_of?(Spectrum::GrayScale) and
54
- ((@g - other.g).abs <= Spectrum::COLOR_TOLERANCE)
55
- end
56
-
57
- # Present the colour as a DeviceGrey fill colour string for PDF. This will
58
- # be removed from the default package in color-tools 2.0.
59
- def pdf_fill
60
- PDF_FORMAT_STR % [ @g, "g" ]
61
- end
62
-
63
- # Present the colour as a DeviceGrey stroke colour string for PDF. This
64
- # will be removed from the default package in color-tools 2.0.
65
- def pdf_stroke
66
- PDF_FORMAT_STR % [ @g, "G" ]
67
- end
68
-
69
- def to_255
70
- [(@g * 255).round, 255].min
71
- end
72
- private :to_255
73
-
74
- # Present the colour as an HTML/CSS colour string.
75
- def html
76
- gs = "%02x" % to_255
77
- "##{gs * 3}"
78
- end
79
-
80
- # Present the colour as an RGB HTML/CSS colour string (e.g., "rgb(0%, 50%,
81
- # 100%)").
82
- def css_rgb
83
- "rgb(%3.2f%%, %3.2f%%, %3.2f%%)" % [ gray, gray, gray ]
84
- end
85
-
86
- # Present the colour as an RGBA (with alpha) HTML/CSS colour string (e.g.,
87
- # "rgb(0%, 50%, 100%, 1)").
88
- def css_rgba
89
- "rgba(%3.2f%%, %3.2f%%, %3.2f%%, %1.2f)" % [ gray, gray, gray, 1 ]
90
- end
91
-
92
- # Present the colour as an HSL HTML/CSS colour string (e.g., "hsl(180,
93
- # 25%, 35%)"). Note that this will perform a #to_hsl operation.
94
- def css_hsl
95
- to_hsl.css_hsl
96
- end
97
-
98
- # Present the colour as an HSLA (with alpha) HTML/CSS colour string (e.g.,
99
- # "hsla(180, 25%, 35%, 1)"). Note that this will perform a #to_hsl
100
- # operation.
101
- def css_hsla
102
- to_hsl.css_hsla
103
- end
104
-
105
- # Convert the greyscale colour to CMYK.
106
- def to_cmyk
107
- k = 1.0 - @g.to_f
108
- Spectrum::CMYK.from_fraction(0, 0, 0, k)
109
- end
110
-
111
- # Convert the greyscale colour to RGB.
112
- def to_rgb(ignored = true)
113
- Spectrum::RGB.from_fraction(g, g, g)
114
- end
115
-
116
- # Reflexive conversion.
117
- def to_grayscale
118
- self
119
- end
120
- alias to_greyscale to_grayscale
121
-
122
- # Lightens the greyscale colour by the stated percent.
123
- def lighten_by(percent)
124
- g = [@g + (@g * (percent / 100.0)), 1.0].min
125
- Spectrum::GrayScale.from_fraction(g)
126
- end
127
-
128
- # Darken the greyscale colour by the stated percent.
129
- def darken_by(percent)
130
- g = [@g - (@g * (percent / 100.0)), 0.0].max
131
- Spectrum::GrayScale.from_fraction(g)
132
- end
133
-
134
- # Returns the YIQ (NTSC) colour encoding of the greyscale value. This is
135
- # an approximation, as the values for I and Q are calculated by treating
136
- # the greyscale value as an RGB value. The Y (intensity or brightness)
137
- # value is the same as the greyscale value.
138
- def to_yiq
139
- y = @g
140
- i = (@g * 0.596) + (@g * -0.275) + (@g * -0.321)
141
- q = (@g * 0.212) + (@g * -0.523) + (@g * 0.311)
142
- Spectrum::YIQ.from_fraction(y, i, q)
143
- end
144
-
145
- # Returns the HSL colour encoding of the greyscale value.
146
- def to_hsl
147
- Spectrum::HSL.from_fraction(0, 0, @g)
148
- end
149
-
150
- # Returns the brightness value for this greyscale value; this is the
151
- # greyscale value itself.
152
- def brightness
153
- @g
154
- end
155
-
156
- # Returns the grayscale value as a percentage of white (100% gray is
157
- # white).
158
- def gray
159
- @g * 100.0
160
- end
161
- alias grey gray
162
- # Returns the grayscale value as a fractional value of white in the range
163
- # 0.0 .. 1.0.
164
- def g
165
- @g
166
- end
167
- # Sets the grayscale value as a percentage of white.
168
- def gray=(gg)
169
- @g = Spectrum.normalize(gg / 100.0)
170
- end
171
- alias grey= gray= ;
172
- # Returns the grayscale value as a fractional value of white in the range
173
- # 0.0 .. 1.0.
174
- def g=(gg)
175
- @g = Spectrum.normalize(gg)
176
- end
177
-
178
- # Adds another colour to the current colour. The other colour will be
179
- # converted to grayscale before addition. This conversion depends upon a
180
- # #to_grayscale method on the other colour.
181
- #
182
- # The addition is done using the grayscale accessor methods to ensure a
183
- # valid colour in the result.
184
- def +(other)
185
- other = other.to_grayscale
186
- ng = self.dup
187
- ng.g += other.g
188
- ng
189
- end
190
-
191
- # Subtracts another colour to the current colour. The other colour will be
192
- # converted to grayscale before subtraction. This conversion depends upon
193
- # a #to_grayscale method on the other colour.
194
- #
195
- # The subtraction is done using the grayscale accessor methods to ensure a
196
- # valid colour in the result.
197
- def -(other)
198
- other = other.to_grayscale
199
- ng = self.dup
200
- ng.g -= other.g
201
- ng
202
- end
203
-
204
- def inspect
205
- "Gray [%.2f%%]" % [ gray ]
206
- end
207
- end
208
-
209
- module Spectrum
210
- # A synonym for Spectrum::GrayScale.
211
- GreyScale = GrayScale
212
- end