color 1.4.1 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +3 -3
- data/.gemtest +0 -0
- data/.hoerc +2 -0
- data/Contributing.rdoc +57 -0
- data/{History.txt → History.rdoc} +18 -13
- data/{Licence.txt → Licence.rdoc} +4 -4
- data/Manifest.txt +4 -6
- data/README.rdoc +45 -0
- data/Rakefile +29 -111
- data/lib/color.rb +4 -16
- data/lib/color/cmyk.rb +0 -12
- data/lib/color/css.rb +0 -12
- data/lib/color/grayscale.rb +3 -17
- data/lib/color/hsl.rb +0 -12
- data/lib/color/palette.rb +0 -12
- data/lib/color/palette/adobecolor.rb +0 -12
- data/lib/color/palette/gimp.rb +0 -12
- data/lib/color/palette/monocontrast.rb +3 -15
- data/lib/color/rgb-colors.rb +0 -12
- data/lib/color/rgb.rb +4 -16
- data/lib/color/rgb/metallic.rb +0 -12
- data/lib/color/yiq.rb +1 -13
- data/test/test_adobecolor.rb +9 -23
- data/test/test_cmyk.rb +20 -36
- data/test/test_color.rb +4 -16
- data/test/test_css.rb +3 -15
- data/test/test_gimp.rb +8 -22
- data/test/test_grayscale.rb +11 -27
- data/test/test_hsl.rb +20 -38
- data/test/test_monocontrast.rb +13 -25
- data/test/test_rgb.rb +20 -32
- data/test/test_yiq.rb +12 -24
- metadata +271 -99
- metadata.gz.sig +1 -3
- data/Install.txt +0 -18
- data/README.txt +0 -32
- data/setup.rb +0 -1585
- data/test/test_all.rb +0 -23
data/test/test_gimp.rb
CHANGED
@@ -1,24 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
# Color
|
4
|
-
# Colour management with Ruby
|
5
|
-
# http://rubyforge.org/projects/color
|
6
|
-
# Version 1.5.0
|
7
|
-
#
|
8
|
-
# Licensed under a MIT-style licence. See Licence.txt in the main
|
9
|
-
# distribution for full licensing information.
|
10
|
-
#
|
11
|
-
# Copyright (c) 2005 - 2010 Austin Ziegler and Matt Lyon
|
12
|
-
#++
|
1
|
+
gem 'minitest'
|
2
|
+
require 'minitest/autorun'
|
13
3
|
|
14
|
-
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../lib") if __FILE__ == $0
|
15
|
-
require 'test/unit'
|
16
4
|
require 'color'
|
17
5
|
require 'color/palette/gimp'
|
18
6
|
|
19
7
|
module TestColor
|
20
8
|
module TestPalette
|
21
|
-
class TestGimp < Test
|
9
|
+
class TestGimp < Minitest::Test
|
22
10
|
include Color::Palette
|
23
11
|
|
24
12
|
GIMP_W3C = <<-EOS
|
@@ -43,7 +31,7 @@ Columns: 2
|
|
43
31
|
0 128 0 Green
|
44
32
|
0 0 255 Blue
|
45
33
|
0 0 128 Navy
|
46
|
-
0 0 0 Black
|
34
|
+
0 0 0 Black
|
47
35
|
EOS
|
48
36
|
|
49
37
|
def setup
|
@@ -64,7 +52,7 @@ Columns: 2
|
|
64
52
|
def test_each_name
|
65
53
|
@gimp = Gimp.new(GIMP_W3C)
|
66
54
|
assert_equal(16, @gimp.instance_variable_get(:@names).size)
|
67
|
-
|
55
|
+
|
68
56
|
@gimp.each_name { |color_name, color_set|
|
69
57
|
assert_kind_of(Array, color_set)
|
70
58
|
color_set.each { |c|
|
@@ -74,12 +62,10 @@ Columns: 2
|
|
74
62
|
end
|
75
63
|
|
76
64
|
def test_index
|
77
|
-
|
78
|
-
|
79
|
-
f.write GIMP_W3C
|
80
|
-
end
|
65
|
+
File.open(@filename, "wb") do |f|
|
66
|
+
f.write GIMP_W3C
|
81
67
|
end
|
82
|
-
|
68
|
+
@gimp = Gimp.from_file(@filename)
|
83
69
|
assert_equal(Color::RGB::White, @gimp[0])
|
84
70
|
assert_equal(Color::RGB::White, @gimp["White"][0])
|
85
71
|
assert_equal([Color::RGB::White, Color::RGB::Black],
|
data/test/test_grayscale.rb
CHANGED
@@ -1,22 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
# Colour management with Ruby
|
5
|
-
# http://rubyforge.org/projects/color
|
6
|
-
# Version 1.5.0
|
7
|
-
#
|
8
|
-
# Licensed under a MIT-style licence. See Licence.txt in the main
|
9
|
-
# distribution for full licensing information.
|
10
|
-
#
|
11
|
-
# Copyright (c) 2005 - 2010 Austin Ziegler and Matt Lyon
|
12
|
-
#++
|
13
|
-
|
14
|
-
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../lib") if __FILE__ == $0
|
15
|
-
require 'test/unit'
|
1
|
+
gem 'minitest'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
|
16
4
|
require 'color'
|
17
5
|
|
18
6
|
module TestColor
|
19
|
-
class TestGrayScale < Test
|
7
|
+
class TestGrayScale < Minitest::Test
|
20
8
|
def setup
|
21
9
|
@gs = Color::GrayScale.from_percent(33)
|
22
10
|
end
|
@@ -32,11 +20,11 @@ module TestColor
|
|
32
20
|
def test_g
|
33
21
|
assert_in_delta(0.33, @gs.g, Color::COLOR_TOLERANCE)
|
34
22
|
assert_in_delta(33, @gs.grey, Color::COLOR_TOLERANCE)
|
35
|
-
|
23
|
+
@gs.gray = 40
|
36
24
|
assert_in_delta(0.4, @gs.g, Color::COLOR_TOLERANCE)
|
37
|
-
|
25
|
+
@gs.g = 2.0
|
38
26
|
assert_in_delta(100, @gs.gray, Color::COLOR_TOLERANCE)
|
39
|
-
|
27
|
+
@gs.grey = -2.0
|
40
28
|
assert_in_delta(0.0, @gs.g, Color::COLOR_TOLERANCE)
|
41
29
|
end
|
42
30
|
|
@@ -56,8 +44,7 @@ module TestColor
|
|
56
44
|
end
|
57
45
|
|
58
46
|
def test_to_cmyk
|
59
|
-
cmyk =
|
60
|
-
assert_nothing_raised { cmyk = @gs.to_cmyk }
|
47
|
+
cmyk = @gs.to_cmyk
|
61
48
|
assert_kind_of(Color::CMYK, cmyk)
|
62
49
|
assert_in_delta(0.0, cmyk.c, Color::COLOR_TOLERANCE)
|
63
50
|
assert_in_delta(0.0, cmyk.m, Color::COLOR_TOLERANCE)
|
@@ -71,8 +58,7 @@ module TestColor
|
|
71
58
|
end
|
72
59
|
|
73
60
|
def test_to_hsl
|
74
|
-
hsl =
|
75
|
-
assert_nothing_raised { hsl = @gs.to_hsl }
|
61
|
+
hsl = @gs.to_hsl
|
76
62
|
assert_kind_of(Color::HSL, hsl)
|
77
63
|
assert_in_delta(0.0, hsl.h, Color::COLOR_TOLERANCE)
|
78
64
|
assert_in_delta(0.0, hsl.s, Color::COLOR_TOLERANCE)
|
@@ -82,8 +68,7 @@ module TestColor
|
|
82
68
|
end
|
83
69
|
|
84
70
|
def test_to_rgb
|
85
|
-
rgb =
|
86
|
-
assert_nothing_raised { rgb = @gs.to_rgb }
|
71
|
+
rgb = @gs.to_rgb
|
87
72
|
assert_kind_of(Color::RGB, rgb)
|
88
73
|
assert_in_delta(0.33, rgb.r, Color::COLOR_TOLERANCE)
|
89
74
|
assert_in_delta(0.33, rgb.g, Color::COLOR_TOLERANCE)
|
@@ -91,8 +76,7 @@ module TestColor
|
|
91
76
|
end
|
92
77
|
|
93
78
|
def test_to_yiq
|
94
|
-
yiq =
|
95
|
-
assert_nothing_raised { yiq = @gs.to_yiq }
|
79
|
+
yiq = @gs.to_yiq
|
96
80
|
assert_kind_of(Color::YIQ, yiq)
|
97
81
|
assert_in_delta(0.33, yiq.y, Color::COLOR_TOLERANCE)
|
98
82
|
assert_in_delta(0.0, yiq.i, Color::COLOR_TOLERANCE)
|
data/test/test_hsl.rb
CHANGED
@@ -1,24 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
# Color
|
4
|
-
# Colour management with Ruby
|
5
|
-
# http://rubyforge.org/projects/color
|
6
|
-
# Version 1.5.0
|
7
|
-
#
|
8
|
-
# Licensed under a MIT-style licence. See Licence.txt in the main
|
9
|
-
# distribution for full licensing information.
|
10
|
-
#
|
11
|
-
# Copyright (c) 2005 - 2010 Austin Ziegler and Matt Lyon
|
12
|
-
#
|
13
|
-
# HSL Tests provided by Adam Johnson
|
14
|
-
#++
|
1
|
+
gem 'minitest'
|
2
|
+
require 'minitest/autorun'
|
15
3
|
|
16
|
-
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../lib") if __FILE__ == $0
|
17
|
-
require 'test/unit'
|
18
4
|
require 'color'
|
19
5
|
|
20
6
|
module TestColor
|
21
|
-
class TestHSL < Test
|
7
|
+
class TestHSL < Minitest::Test
|
22
8
|
def setup
|
23
9
|
# @hsl = Color::HSL.new(262, 67, 42)
|
24
10
|
@hsl = Color::HSL.new(145, 20, 30)
|
@@ -40,40 +26,40 @@ module TestColor
|
|
40
26
|
def test_hue
|
41
27
|
assert_in_delta 0.4027, @hsl.h, Color::COLOR_TOLERANCE
|
42
28
|
assert_in_delta 145, @hsl.hue, Color::COLOR_TOLERANCE
|
43
|
-
|
29
|
+
@hsl.hue = 33
|
44
30
|
assert_in_delta 0.09167, @hsl.h, Color::COLOR_TOLERANCE
|
45
|
-
|
31
|
+
@hsl.hue = -33
|
46
32
|
assert_in_delta 0.90833, @hsl.h, Color::COLOR_TOLERANCE
|
47
|
-
|
33
|
+
@hsl.h = 3.3
|
48
34
|
assert_in_delta 360, @hsl.hue, Color::COLOR_TOLERANCE
|
49
|
-
|
35
|
+
@hsl.h = -3.3
|
50
36
|
assert_in_delta 0.0, @hsl.h, Color::COLOR_TOLERANCE
|
51
|
-
|
52
|
-
|
37
|
+
@hsl.hue = 0
|
38
|
+
@hsl.hue -= 20
|
53
39
|
assert_in_delta 340, @hsl.hue, Color::COLOR_TOLERANCE
|
54
|
-
|
40
|
+
@hsl.hue += 45
|
55
41
|
assert_in_delta 25, @hsl.hue, Color::COLOR_TOLERANCE
|
56
42
|
end
|
57
43
|
|
58
44
|
def test_saturation
|
59
45
|
assert_in_delta 0.2, @hsl.s, Color::COLOR_TOLERANCE
|
60
46
|
assert_in_delta 20, @hsl.saturation, Color::COLOR_TOLERANCE
|
61
|
-
|
47
|
+
@hsl.saturation = 33
|
62
48
|
assert_in_delta 0.33, @hsl.s, Color::COLOR_TOLERANCE
|
63
|
-
|
49
|
+
@hsl.s = 3.3
|
64
50
|
assert_in_delta 100, @hsl.saturation, Color::COLOR_TOLERANCE
|
65
|
-
|
51
|
+
@hsl.s = -3.3
|
66
52
|
assert_in_delta 0.0, @hsl.s, Color::COLOR_TOLERANCE
|
67
53
|
end
|
68
54
|
|
69
55
|
def test_luminance
|
70
56
|
assert_in_delta 0.3, @hsl.l, Color::COLOR_TOLERANCE
|
71
57
|
assert_in_delta 30, @hsl.luminosity, Color::COLOR_TOLERANCE
|
72
|
-
|
58
|
+
@hsl.luminosity = 33
|
73
59
|
assert_in_delta 0.33, @hsl.l, Color::COLOR_TOLERANCE
|
74
|
-
|
60
|
+
@hsl.l = 3.3
|
75
61
|
assert_in_delta 100, @hsl.lightness, Color::COLOR_TOLERANCE
|
76
|
-
|
62
|
+
@hsl.l = -3.3
|
77
63
|
assert_in_delta 0.0, @hsl.l, Color::COLOR_TOLERANCE
|
78
64
|
end
|
79
65
|
|
@@ -83,8 +69,7 @@ module TestColor
|
|
83
69
|
end
|
84
70
|
|
85
71
|
def test_to_cmyk
|
86
|
-
cmyk =
|
87
|
-
assert_nothing_raised { cmyk = @hsl.to_cmyk }
|
72
|
+
cmyk = @hsl.to_cmyk
|
88
73
|
assert_kind_of Color::CMYK, cmyk
|
89
74
|
assert_in_delta 0.3223, cmyk.c, Color::COLOR_TOLERANCE
|
90
75
|
assert_in_delta 0.2023, cmyk.m, Color::COLOR_TOLERANCE
|
@@ -93,15 +78,13 @@ module TestColor
|
|
93
78
|
end
|
94
79
|
|
95
80
|
def test_to_grayscale
|
96
|
-
gs =
|
97
|
-
assert_nothing_raised { gs = @hsl.to_grayscale }
|
81
|
+
gs = @hsl.to_grayscale
|
98
82
|
assert_kind_of Color::GreyScale, gs
|
99
83
|
assert_in_delta 30, gs.gray, Color::COLOR_TOLERANCE
|
100
84
|
end
|
101
85
|
|
102
86
|
def test_to_rgb
|
103
|
-
rgb =
|
104
|
-
assert_nothing_raised { rgb = @hsl.to_rgb }
|
87
|
+
rgb = @hsl.to_rgb
|
105
88
|
assert_kind_of Color::RGB, rgb
|
106
89
|
assert_in_delta 0.24, rgb.r, Color::COLOR_TOLERANCE
|
107
90
|
assert_in_delta 0.36, rgb.g, Color::COLOR_TOLERANCE
|
@@ -125,8 +108,7 @@ module TestColor
|
|
125
108
|
end
|
126
109
|
|
127
110
|
def test_to_yiq
|
128
|
-
yiq =
|
129
|
-
assert_nothing_raised { yiq = @hsl.to_yiq }
|
111
|
+
yiq = @hsl.to_yiq
|
130
112
|
assert_kind_of Color::YIQ, yiq
|
131
113
|
assert_in_delta 0.3161, yiq.y, Color::COLOR_TOLERANCE
|
132
114
|
assert_in_delta 0.0, yiq.i, Color::COLOR_TOLERANCE
|
data/test/test_monocontrast.rb
CHANGED
@@ -1,24 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
# Color
|
4
|
-
# Colour management with Ruby
|
5
|
-
# http://rubyforge.org/projects/color
|
6
|
-
# Version 1.5.0
|
7
|
-
#
|
8
|
-
# Licensed under a MIT-style licence. See Licence.txt in the main
|
9
|
-
# distribution for full licensing information.
|
10
|
-
#
|
11
|
-
# Copyright (c) 2005 - 2010 Austin Ziegler and Matt Lyon
|
12
|
-
#++
|
1
|
+
gem 'minitest'
|
2
|
+
require 'minitest/autorun'
|
13
3
|
|
14
|
-
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../lib") if __FILE__ == $0
|
15
|
-
require 'test/unit'
|
16
4
|
require 'color'
|
17
5
|
require 'color/palette/monocontrast'
|
18
6
|
|
19
7
|
module TestColor
|
20
8
|
module TestPalette
|
21
|
-
class TestMonoContrast < Test
|
9
|
+
class TestMonoContrast < Minitest::Test
|
22
10
|
include Color::Palette
|
23
11
|
def setup
|
24
12
|
@high = Color::RGB.from_html("#c9e3a6")
|
@@ -105,14 +93,14 @@ module TestColor
|
|
105
93
|
assert_in_delta(MonoContrast::DEFAULT_MINIMUM_BRIGHTNESS_DIFF,
|
106
94
|
@mcp1.minimum_brightness_diff, Color::COLOR_TOLERANCE)
|
107
95
|
mcps = @mcp1.dup
|
108
|
-
|
96
|
+
@mcp1.minimum_brightness_diff = 0.75
|
109
97
|
assert_in_delta(0.75, @mcp1.minimum_brightness_diff, Color::COLOR_TOLERANCE)
|
110
|
-
|
111
|
-
|
98
|
+
refute_equal(@mcp1.foreground[-5], mcps.foreground[-5])
|
99
|
+
@mcp1.minimum_brightness_diff = 4.0
|
112
100
|
assert_in_delta(1, @mcp1.minimum_brightness_diff, Color::COLOR_TOLERANCE)
|
113
|
-
|
101
|
+
@mcp1.minimum_brightness_diff = -4.0
|
114
102
|
assert_in_delta(0, @mcp1.minimum_brightness_diff, Color::COLOR_TOLERANCE)
|
115
|
-
|
103
|
+
@mcp1.minimum_brightness_diff = nil
|
116
104
|
assert_in_delta(MonoContrast::DEFAULT_MINIMUM_BRIGHTNESS_DIFF,
|
117
105
|
@mcp1.minimum_brightness_diff, Color::COLOR_TOLERANCE)
|
118
106
|
end
|
@@ -126,14 +114,14 @@ module TestColor
|
|
126
114
|
assert_in_delta(MonoContrast::DEFAULT_MINIMUM_COLOR_DIFF,
|
127
115
|
@mcp1.minimum_color_diff, Color::COLOR_TOLERANCE)
|
128
116
|
mcps = @mcp1.dup
|
129
|
-
|
117
|
+
@mcp1.minimum_color_diff = 0.75
|
130
118
|
assert_in_delta(0.75, @mcp1.minimum_color_diff, Color::COLOR_TOLERANCE)
|
131
|
-
|
132
|
-
|
119
|
+
refute_equal(@mcp1.foreground[-5], mcps.foreground[-5])
|
120
|
+
@mcp1.minimum_color_diff = 4.0
|
133
121
|
assert_in_delta(3, @mcp1.minimum_color_diff, Color::COLOR_TOLERANCE)
|
134
|
-
|
122
|
+
@mcp1.minimum_color_diff = -4.0
|
135
123
|
assert_in_delta(0, @mcp1.minimum_color_diff, Color::COLOR_TOLERANCE)
|
136
|
-
|
124
|
+
@mcp1.minimum_color_diff = nil
|
137
125
|
assert_in_delta(MonoContrast::DEFAULT_MINIMUM_COLOR_DIFF,
|
138
126
|
@mcp1.minimum_color_diff, Color::COLOR_TOLERANCE)
|
139
127
|
end
|
data/test/test_rgb.rb
CHANGED
@@ -1,22 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
# Colour management with Ruby
|
5
|
-
# http://rubyforge.org/projects/color
|
6
|
-
# Version 1.5.0
|
7
|
-
#
|
8
|
-
# Licensed under a MIT-style licence. See Licence.txt in the main
|
9
|
-
# distribution for full licensing information.
|
10
|
-
#
|
11
|
-
# Copyright (c) 2005 - 2010 Austin Ziegler and Matt Lyon
|
12
|
-
#++
|
13
|
-
|
14
|
-
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../lib") if __FILE__ == $0
|
15
|
-
require 'test/unit'
|
1
|
+
gem 'minitest'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
|
16
4
|
require 'color'
|
17
5
|
|
18
6
|
module TestColor
|
19
|
-
class TestRGB < Test
|
7
|
+
class TestRGB < Minitest::Test
|
20
8
|
def test_adjust_brightness
|
21
9
|
assert_equal("#1a1aff", Color::RGB::Blue.adjust_brightness(10).html)
|
22
10
|
assert_equal("#0000e6", Color::RGB::Blue.adjust_brightness(-10).html)
|
@@ -40,11 +28,11 @@ module TestColor
|
|
40
28
|
assert_in_delta(100, red.red_p, Color::COLOR_TOLERANCE)
|
41
29
|
assert_in_delta(255, red.red, Color::COLOR_TOLERANCE)
|
42
30
|
assert_in_delta(1.0, red.r, Color::COLOR_TOLERANCE)
|
43
|
-
|
31
|
+
red.red_p = 33
|
44
32
|
assert_in_delta(0.33, red.r, Color::COLOR_TOLERANCE)
|
45
|
-
|
33
|
+
red.red = 330
|
46
34
|
assert_in_delta(1.0, red.r, Color::COLOR_TOLERANCE)
|
47
|
-
|
35
|
+
red.r = -3.3
|
48
36
|
assert_in_delta(0.0, red.r, Color::COLOR_TOLERANCE)
|
49
37
|
end
|
50
38
|
|
@@ -53,11 +41,11 @@ module TestColor
|
|
53
41
|
assert_in_delta(1.0, lime.g, Color::COLOR_TOLERANCE)
|
54
42
|
assert_in_delta(100, lime.green_p, Color::COLOR_TOLERANCE)
|
55
43
|
assert_in_delta(255, lime.green, Color::COLOR_TOLERANCE)
|
56
|
-
|
44
|
+
lime.green_p = 33
|
57
45
|
assert_in_delta(0.33, lime.g, Color::COLOR_TOLERANCE)
|
58
|
-
|
46
|
+
lime.green = 330
|
59
47
|
assert_in_delta(1.0, lime.g, Color::COLOR_TOLERANCE)
|
60
|
-
|
48
|
+
lime.g = -3.3
|
61
49
|
assert_in_delta(0.0, lime.g, Color::COLOR_TOLERANCE)
|
62
50
|
end
|
63
51
|
|
@@ -66,11 +54,11 @@ module TestColor
|
|
66
54
|
assert_in_delta(1.0, blue.b, Color::COLOR_TOLERANCE)
|
67
55
|
assert_in_delta(255, blue.blue, Color::COLOR_TOLERANCE)
|
68
56
|
assert_in_delta(100, blue.blue_p, Color::COLOR_TOLERANCE)
|
69
|
-
|
57
|
+
blue.blue_p = 33
|
70
58
|
assert_in_delta(0.33, blue.b, Color::COLOR_TOLERANCE)
|
71
|
-
|
59
|
+
blue.blue = 330
|
72
60
|
assert_in_delta(1.0, blue.b, Color::COLOR_TOLERANCE)
|
73
|
-
|
61
|
+
blue.b = -3.3
|
74
62
|
assert_in_delta(0.0, blue.b, Color::COLOR_TOLERANCE)
|
75
63
|
end
|
76
64
|
|
@@ -254,7 +242,7 @@ module TestColor
|
|
254
242
|
# where HSL conversion was not quite correct, resulting in a bad
|
255
243
|
# round-trip.
|
256
244
|
assert_equal("#008800", Color::RGB.from_html("#008800").to_hsl.html)
|
257
|
-
|
245
|
+
refute_equal("#002288", Color::RGB.from_html("#008800").to_hsl.html)
|
258
246
|
|
259
247
|
# The following tests a bug reported by Adam Johnson on 29 October
|
260
248
|
# 2010.
|
@@ -290,10 +278,10 @@ module TestColor
|
|
290
278
|
end
|
291
279
|
|
292
280
|
def test_add
|
293
|
-
|
294
|
-
white = Color::RGB::Cyan + Color::RGB::Yellow
|
295
|
-
|
296
|
-
assert_equal(Color::RGB::White, white)
|
281
|
+
Color::RGB::Cyan + Color::RGB::Yellow
|
282
|
+
white = Color::RGB::Cyan + Color::RGB::Yellow
|
283
|
+
refute_nil(white)
|
284
|
+
assert_equal(Color::RGB::White, white)
|
297
285
|
|
298
286
|
c1 = Color::RGB.new(0x80, 0x80, 0x00)
|
299
287
|
c2 = Color::RGB.new(0x45, 0x20, 0xf0)
|
@@ -304,7 +292,7 @@ module TestColor
|
|
304
292
|
|
305
293
|
def test_subtract
|
306
294
|
black = Color::RGB::LightCoral - Color::RGB::Honeydew
|
307
|
-
assert_equal(Color::RGB::Black, black)
|
295
|
+
assert_equal(Color::RGB::Black, black)
|
308
296
|
|
309
297
|
c1 = Color::RGB.new(0x85, 0x80, 0x00)
|
310
298
|
c2 = Color::RGB.new(0x40, 0x20, 0xf0)
|
@@ -315,7 +303,7 @@ module TestColor
|
|
315
303
|
|
316
304
|
def test_mean_grayscale
|
317
305
|
c1 = Color::RGB.new(0x85, 0x80, 0x00)
|
318
|
-
c1_max =
|
306
|
+
c1_max = c1.max_rgb_as_greyscale
|
319
307
|
c1_max = c1.max_rgb_as_greyscale
|
320
308
|
c1_result = Color::GrayScale.from_fraction(0x85 / 255.0)
|
321
309
|
|
data/test/test_yiq.rb
CHANGED
@@ -1,22 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
# Color
|
4
|
-
# Colour management with Ruby
|
5
|
-
# http://rubyforge.org/projects/color
|
6
|
-
# Version 1.5.0
|
7
|
-
#
|
8
|
-
# Licensed under a MIT-style licence. See Licence.txt in the main
|
9
|
-
# distribution for full licensing information.
|
10
|
-
#
|
11
|
-
# Copyright (c) 2005 - 2010 Austin Ziegler and Matt Lyon
|
12
|
-
#++
|
1
|
+
gem 'minitest'
|
2
|
+
require 'minitest/autorun'
|
13
3
|
|
14
|
-
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../lib") if __FILE__ == $0
|
15
|
-
require 'test/unit'
|
16
4
|
require 'color'
|
17
5
|
|
18
6
|
module TestColor
|
19
|
-
class TestYIQ < Test
|
7
|
+
class TestYIQ < Minitest::Test
|
20
8
|
def setup
|
21
9
|
@yiq = Color::YIQ.from_fraction(0.1, 0.2, 0.3)
|
22
10
|
end
|
@@ -28,22 +16,22 @@ module TestColor
|
|
28
16
|
def test_i
|
29
17
|
assert_in_delta(0.2, @yiq.i, Color::COLOR_TOLERANCE)
|
30
18
|
assert_in_delta(0.2, @yiq.i, Color::COLOR_TOLERANCE)
|
31
|
-
|
19
|
+
@yiq.i = 0.5
|
32
20
|
assert_in_delta(0.5, @yiq.i, Color::COLOR_TOLERANCE)
|
33
|
-
|
21
|
+
@yiq.i = 5
|
34
22
|
assert_in_delta(1.0, @yiq.i, Color::COLOR_TOLERANCE)
|
35
|
-
|
23
|
+
@yiq.i = -5
|
36
24
|
assert_in_delta(0.0, @yiq.i, Color::COLOR_TOLERANCE)
|
37
25
|
end
|
38
26
|
|
39
27
|
def test_q
|
40
28
|
assert_in_delta(0.3, @yiq.q, Color::COLOR_TOLERANCE)
|
41
29
|
assert_in_delta(0.3, @yiq.q, Color::COLOR_TOLERANCE)
|
42
|
-
|
30
|
+
@yiq.q = 0.5
|
43
31
|
assert_in_delta(0.5, @yiq.q, Color::COLOR_TOLERANCE)
|
44
|
-
|
32
|
+
@yiq.q = 5
|
45
33
|
assert_in_delta(1.0, @yiq.q, Color::COLOR_TOLERANCE)
|
46
|
-
|
34
|
+
@yiq.q = -5
|
47
35
|
assert_in_delta(0.0, @yiq.q, Color::COLOR_TOLERANCE)
|
48
36
|
end
|
49
37
|
|
@@ -58,11 +46,11 @@ module TestColor
|
|
58
46
|
def test_y
|
59
47
|
assert_in_delta(0.1, @yiq.y, Color::COLOR_TOLERANCE)
|
60
48
|
assert_in_delta(0.1, @yiq.y, Color::COLOR_TOLERANCE)
|
61
|
-
|
49
|
+
@yiq.y = 0.5
|
62
50
|
assert_in_delta(0.5, @yiq.y, Color::COLOR_TOLERANCE)
|
63
|
-
|
51
|
+
@yiq.y = 5
|
64
52
|
assert_in_delta(1.0, @yiq.y, Color::COLOR_TOLERANCE)
|
65
|
-
|
53
|
+
@yiq.y = -5
|
66
54
|
assert_in_delta(0.0, @yiq.y, Color::COLOR_TOLERANCE)
|
67
55
|
end
|
68
56
|
|