color 1.8 → 2.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.
Files changed (53) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +314 -0
  3. data/CODE_OF_CONDUCT.md +128 -0
  4. data/CONTRIBUTING.md +84 -0
  5. data/CONTRIBUTORS.md +11 -0
  6. data/LICENCE.md +50 -0
  7. data/Manifest.txt +12 -23
  8. data/README.md +54 -0
  9. data/Rakefile +72 -61
  10. data/SECURITY.md +39 -0
  11. data/lib/color/cielab.rb +348 -0
  12. data/lib/color/cmyk.rb +279 -213
  13. data/lib/color/grayscale.rb +128 -160
  14. data/lib/color/hsl.rb +205 -173
  15. data/lib/color/rgb/colors.rb +211 -161
  16. data/lib/color/rgb.rb +527 -551
  17. data/lib/color/version.rb +5 -0
  18. data/lib/color/xyz.rb +214 -0
  19. data/lib/color/yiq.rb +91 -46
  20. data/lib/color.rb +204 -142
  21. data/licences/dco.txt +34 -0
  22. data/test/fixtures/cielab.json +444 -0
  23. data/test/minitest_helper.rb +20 -4
  24. data/test/test_cmyk.rb +49 -72
  25. data/test/test_color.rb +58 -112
  26. data/test/test_grayscale.rb +35 -57
  27. data/test/test_hsl.rb +71 -77
  28. data/test/test_rgb.rb +195 -267
  29. data/test/test_yiq.rb +12 -30
  30. metadata +104 -121
  31. data/.autotest +0 -5
  32. data/.coveralls.yml +0 -2
  33. data/.gemtest +0 -0
  34. data/.hoerc +0 -2
  35. data/.minitest.rb +0 -2
  36. data/.travis.yml +0 -41
  37. data/Code-of-Conduct.rdoc +0 -41
  38. data/Contributing.rdoc +0 -62
  39. data/Gemfile +0 -9
  40. data/History.rdoc +0 -194
  41. data/Licence.rdoc +0 -27
  42. data/README.rdoc +0 -52
  43. data/lib/color/css.rb +0 -7
  44. data/lib/color/palette/adobecolor.rb +0 -260
  45. data/lib/color/palette/gimp.rb +0 -104
  46. data/lib/color/palette/monocontrast.rb +0 -164
  47. data/lib/color/palette.rb +0 -4
  48. data/lib/color/rgb/contrast.rb +0 -57
  49. data/lib/color/rgb/metallic.rb +0 -28
  50. data/test/test_adobecolor.rb +0 -405
  51. data/test/test_css.rb +0 -19
  52. data/test/test_gimp.rb +0 -87
  53. data/test/test_monocontrast.rb +0 -130
data/test/test_gimp.rb DELETED
@@ -1,87 +0,0 @@
1
- # -*- ruby encoding: utf-8 -*-
2
-
3
- require 'color'
4
- require 'color/palette/gimp'
5
- require 'minitest_helper'
6
-
7
- module TestColor
8
- module TestPalette
9
- class TestGimp < Minitest::Test
10
- include Color::Palette
11
-
12
- GIMP_W3C = <<-EOS
13
- GIMP Palette
14
- Name: W3C Named Colors
15
- Columns: 2
16
- #
17
- # ColorZilla W3C Named Colors
18
- #
19
- 255 255 255 White
20
- 255 255 0 Yclow
21
- 255 0 255 Fuchsia
22
- 255 0 0 Red
23
- 192 192 192 Silver
24
- 128 128 128 Gray
25
- 128 128 0 Olive
26
- 128 0 128 Purple
27
- 128 0 0 Maroon
28
- 0 255 255 Aqua
29
- 0 255 0 Lime
30
- 0 128 128 Teal
31
- 0 128 0 Green
32
- 0 0 255 Blue
33
- 0 0 128 Navy
34
- 0 0 0 Black
35
- EOS
36
-
37
- def setup
38
- @filename = "test#{Process.pid}.gimp"
39
- end
40
-
41
- def teardown
42
- require 'fileutils'
43
- FileUtils.rm_f @filename if File.exist? @filename
44
- end
45
-
46
- def test_each
47
- @gimp = Gimp.new(GIMP_W3C)
48
- assert_equal(16, @gimp.instance_variable_get(:@colors).size)
49
- @gimp.each { |c| assert_kind_of(Color::RGB, c) }
50
- end
51
-
52
- def test_each_name
53
- @gimp = Gimp.new(GIMP_W3C)
54
- assert_equal(16, @gimp.instance_variable_get(:@names).size)
55
-
56
- @gimp.each_name { |color_name, color_set|
57
- assert_kind_of(Array, color_set)
58
- color_set.each { |c|
59
- assert_kind_of(Color::RGB, c)
60
- }
61
- }
62
- end
63
-
64
- def test_index
65
- File.open(@filename, "wb") do |f|
66
- f.write GIMP_W3C
67
- end
68
- @gimp = Gimp.from_file(@filename)
69
- assert_equal(Color::RGB::White, @gimp[0])
70
- assert_equal(Color::RGB::White, @gimp["White"][0])
71
- assert_equal([Color::RGB::White, Color::RGB::Black],
72
- @gimp.values_at(0, -1))
73
- assert_equal(16, @gimp.size)
74
- end
75
-
76
- def test_valid_eh
77
- @gimp = Gimp.new(GIMP_W3C)
78
- assert(@gimp.valid?)
79
- end
80
-
81
- def test_name
82
- @gimp = Gimp.new(GIMP_W3C)
83
- assert_equal("W3C Named Colors", @gimp.name)
84
- end
85
- end
86
- end
87
- end
@@ -1,130 +0,0 @@
1
- # -*- ruby encoding: utf-8 -*-
2
-
3
- require 'color'
4
- require 'color/palette/monocontrast'
5
- require 'minitest_helper'
6
-
7
- module TestColor
8
- module TestPalette
9
- class TestMonoContrast < Minitest::Test
10
- include Color::Palette
11
- def setup
12
- @high = Color::RGB.from_html("#c9e3a6")
13
- @low = Color::RGB.from_html("#746b8e")
14
- @mcp1 = MonoContrast.new(@high)
15
- @mcp2 = MonoContrast.new(@low)
16
- end
17
-
18
- def test_background
19
- assert_equal("#141711", @mcp1.background[-5].html)
20
- assert_equal("#32392a", @mcp1.background[-4].html)
21
- assert_equal("#657253", @mcp1.background[-3].html)
22
- assert_equal("#97aa7d", @mcp1.background[-2].html)
23
- assert_equal("#abc18d", @mcp1.background[-1].html)
24
- assert_equal("#c9e3a6", @mcp1.background[ 0].html)
25
- assert_equal("#d1e7b3", @mcp1.background[+1].html)
26
- assert_equal("#d7eabc", @mcp1.background[+2].html) # d7eabd
27
- assert_equal("#e4f1d3", @mcp1.background[+3].html) # e5f2d3
28
- assert_equal("#f2f8e9", @mcp1.background[+4].html) # f1f8e9
29
- assert_equal("#fafcf6", @mcp1.background[+5].html) # fafdf7
30
-
31
- assert_equal("#0c0b0e", @mcp2.background[-5].html)
32
- assert_equal("#1d1b24", @mcp2.background[-4].html)
33
- assert_equal("#3a3647", @mcp2.background[-3].html)
34
- assert_equal("#57506b", @mcp2.background[-2].html)
35
- assert_equal("#635b79", @mcp2.background[-1].html)
36
- assert_equal("#746b8e", @mcp2.background[ 0].html)
37
- assert_equal("#89819f", @mcp2.background[+1].html)
38
- assert_equal("#9790aa", @mcp2.background[+2].html) # 9790ab
39
- assert_equal("#bab5c7", @mcp2.background[+3].html) # bab6c7
40
- assert_equal("#dcdae3", @mcp2.background[+4].html)
41
- assert_equal("#f1f0f4", @mcp2.background[+5].html) # f2f1f4
42
- end
43
-
44
- def test_brightness_diff
45
- bd1 = @mcp1.brightness_diff(@high, @low)
46
- bd2 = @mcp1.brightness_diff(@low, @high)
47
- assert_in_delta(bd1, bd2, Color::COLOR_TOLERANCE)
48
- end
49
-
50
- def test_calculate_foreground
51
- assert_equal("#ffffff", @mcp1.calculate_foreground(@low, @high).html)
52
- assert_equal("#1d1b24", @mcp1.calculate_foreground(@high, @low).html)
53
- end
54
-
55
- def test_color_diff
56
- assert_in_delta(@mcp1.color_diff(@low, @high),
57
- @mcp1.color_diff(@high, @low),
58
- Color::COLOR_TOLERANCE)
59
- end
60
-
61
- def test_foreground
62
- assert_equal("#c9e3a6", @mcp1.foreground[-5].html)
63
- assert_equal("#e4f1d3", @mcp1.foreground[-4].html) # e5f2d3
64
- assert_equal("#ffffff", @mcp1.foreground[-3].html)
65
- assert_equal("#000000", @mcp1.foreground[-2].html)
66
- assert_equal("#000000", @mcp1.foreground[-1].html)
67
- assert_equal("#000000", @mcp1.foreground[ 0].html)
68
- assert_equal("#000000", @mcp1.foreground[+1].html)
69
- assert_equal("#000000", @mcp1.foreground[+2].html)
70
- assert_equal("#32392a", @mcp1.foreground[+3].html)
71
- assert_equal("#32392a", @mcp1.foreground[+4].html)
72
- assert_equal("#32392a", @mcp1.foreground[+5].html)
73
-
74
- assert_equal("#bab5c7", @mcp2.foreground[-5].html) # bab6c7
75
- assert_equal("#dcdae3", @mcp2.foreground[-4].html)
76
- assert_equal("#ffffff", @mcp2.foreground[-3].html)
77
- assert_equal("#ffffff", @mcp2.foreground[-2].html)
78
- assert_equal("#ffffff", @mcp2.foreground[-1].html)
79
- assert_equal("#ffffff", @mcp2.foreground[ 0].html)
80
- assert_equal("#000000", @mcp2.foreground[+1].html)
81
- assert_equal("#000000", @mcp2.foreground[+2].html)
82
- assert_equal("#000000", @mcp2.foreground[+3].html)
83
- assert_equal("#1d1b24", @mcp2.foreground[+4].html)
84
- assert_equal("#3a3647", @mcp2.foreground[+5].html)
85
- end
86
-
87
- def test_minimum_brightness_diff
88
- assert_in_delta(MonoContrast::DEFAULT_MINIMUM_BRIGHTNESS_DIFF,
89
- @mcp1.minimum_brightness_diff, Color::COLOR_TOLERANCE)
90
- end
91
-
92
- def test_minimum_brightness_diff_equals
93
- assert_in_delta(MonoContrast::DEFAULT_MINIMUM_BRIGHTNESS_DIFF,
94
- @mcp1.minimum_brightness_diff, Color::COLOR_TOLERANCE)
95
- mcps = @mcp1.dup
96
- @mcp1.minimum_brightness_diff = 0.75
97
- assert_in_delta(0.75, @mcp1.minimum_brightness_diff, Color::COLOR_TOLERANCE)
98
- refute_equal(@mcp1.foreground[-5], mcps.foreground[-5])
99
- @mcp1.minimum_brightness_diff = 4.0
100
- assert_in_delta(1, @mcp1.minimum_brightness_diff, Color::COLOR_TOLERANCE)
101
- @mcp1.minimum_brightness_diff = -4.0
102
- assert_in_delta(0, @mcp1.minimum_brightness_diff, Color::COLOR_TOLERANCE)
103
- @mcp1.minimum_brightness_diff = nil
104
- assert_in_delta(MonoContrast::DEFAULT_MINIMUM_BRIGHTNESS_DIFF,
105
- @mcp1.minimum_brightness_diff, Color::COLOR_TOLERANCE)
106
- end
107
-
108
- def test_minimum_color_diff
109
- assert_in_delta(MonoContrast::DEFAULT_MINIMUM_COLOR_DIFF,
110
- @mcp1.minimum_color_diff, Color::COLOR_TOLERANCE)
111
- end
112
-
113
- def test_minimum_color_diff_equals
114
- assert_in_delta(MonoContrast::DEFAULT_MINIMUM_COLOR_DIFF,
115
- @mcp1.minimum_color_diff, Color::COLOR_TOLERANCE)
116
- mcps = @mcp1.dup
117
- @mcp1.minimum_color_diff = 0.75
118
- assert_in_delta(0.75, @mcp1.minimum_color_diff, Color::COLOR_TOLERANCE)
119
- refute_equal(@mcp1.foreground[-5], mcps.foreground[-5])
120
- @mcp1.minimum_color_diff = 4.0
121
- assert_in_delta(3, @mcp1.minimum_color_diff, Color::COLOR_TOLERANCE)
122
- @mcp1.minimum_color_diff = -4.0
123
- assert_in_delta(0, @mcp1.minimum_color_diff, Color::COLOR_TOLERANCE)
124
- @mcp1.minimum_color_diff = nil
125
- assert_in_delta(MonoContrast::DEFAULT_MINIMUM_COLOR_DIFF,
126
- @mcp1.minimum_color_diff, Color::COLOR_TOLERANCE)
127
- end
128
- end
129
- end
130
- end