color_lib 1.4.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,404 @@
1
+ require "minitest/autorun"
2
+ require 'test/unit/assertions'
3
+ require 'color_lib'
4
+ require 'color_lib/palette/adobecolor'
5
+
6
+ module TestColorLib
7
+ module TestPalette
8
+ class TestAdobeColorLib < Minitest::Test
9
+ include Test::Unit::Assertions
10
+ include ColorLib::Palette
11
+
12
+ # This is based on the Visibone Anglo-Centric ColorLib Code List; this is
13
+ # an Adobe ColorLib swatch version 1 (RGB colours only).
14
+ VISIBONE_V1 = <<-EOS
15
+ AAEA2AAA/wD/AP8AAAAAAMwAzADMAAAAAACZAJkAmQAAAAAAZgBmAGYAAAAA
16
+ ADMAMwAzAAAAAAAAAAAAAAAAAAAA/wAAAAAAAAAAAP8AMwAzAAAAAADMAAAA
17
+ AAAAAAAA/wBmAGYAAAAAAMwAMwAzAAAAAACZAAAAAAAAAAAA/wCZAJkAAAAA
18
+ AMwAZgBmAAAAAACZADMAMwAAAAAAZgAAAAAAAAAAAP8AzADMAAAAAADMAJkA
19
+ mQAAAAAAmQBmAGYAAAAAAGYAMwAzAAAAAAAzAAAAAAAAAAAA/wAzAAAAAAAA
20
+ AP8AZgAzAAAAAADMADMAAAAAAAAA/wCZAGYAAAAAAMwAZgAzAAAAAACZADMA
21
+ AAAAAAAA/wBmAAAAAAAAAP8AmQAzAAAAAADMAGYAAAAAAAAA/wDMAJkAAAAA
22
+ AMwAmQBmAAAAAACZAGYAMwAAAAAAZgAzAAAAAAAAAP8AmQAAAAAAAAD/AMwA
23
+ ZgAAAAAAzACZADMAAAAAAJkAZgAAAAAAAADMAJkAAAAAAAAA/wDMADMAAAAA
24
+ AP8AzAAAAAAAAAD/AP8AAAAAAAAA/wD/ADMAAAAAAMwAzAAAAAAAAAD/AP8A
25
+ ZgAAAAAAzADMADMAAAAAAJkAmQAAAAAAAAD/AP8AmQAAAAAAzADMAGYAAAAA
26
+ AJkAmQAzAAAAAABmAGYAAAAAAAAA/wD/AM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
+ zAAAAAAAzAAAAJkAAAAAAP8AZgDMAAAAAADMADMAmQAAAAAAmQAAAGYAAAAA
60
+ AP8AAACZAAAAAAD/ADMAmQAAAAAAzAAAAGYAAAAAAP8AmQDMAAAAAADMAGYA
61
+ mQAAAAAAmQAzAGYAAAAAAGYAAAAzAAAAAAD/AAAAZgAAAAAA/wBmAJkAAAAA
62
+ AMwAMwBmAAAAAACZAAAAMwAAAAAA/wAzAGYAAAAAAMwAAAAzAAAAAAD/AAAA
63
+ MwAAAA==
64
+ EOS
65
+
66
+ # This is based on the Visibone Anglo-Centric ColorLib Code List; this is
67
+ # an Adobe ColorLib swatch version 2 (with names).
68
+ VISIBONE_V2 = <<-EOS
69
+ AAIA2AAA/wD/AP8AAAAAAAAGAFcAaABpAHQAZQAAAADMAMwAzAAAAAAAAAoA
70
+ UABhAGwAZQAgAEcAcgBhAHkAAAAAmQCZAJkAAAAAAAALAEwAaQBnAGgAdAAg
71
+ AEcAcgBhAHkAAAAAZgBmAGYAAAAAAAAKAEQAYQByAGsAIABHAHIAYQB5AAAA
72
+ ADMAMwAzAAAAAAAADQBPAGIAcwBjAHUAcgBlACAARwByAGEAeQAAAAAAAAAA
73
+ AAAAAAAAAAYAQgBsAGEAYwBrAAAAAP8AAAAAAAAAAAAABABSAGUAZAAAAAD/
74
+ ADMAMwAAAAAAAA8ATABpAGcAaAB0ACAASABhAHIAZAAgAFIAZQBkAAAAAMwA
75
+ AAAAAAAAAAAADgBEAGEAcgBrACAASABhAHIAZAAgAFIAZQBkAAAAAP8AZgBm
76
+ AAAAAAAAEABMAGkAZwBoAHQAIABGAGEAZABlAGQAIABSAGUAZAAAAADMADMA
77
+ MwAAAAAAABEATQBlAGQAaQB1AG0AIABGAGEAZABlAGQAIABSAGUAZAAAAACZ
78
+ AAAAAAAAAAAAAA8ARABhAHIAawAgAEYAYQBkAGUAZAAgAFIAZQBkAAAAAP8A
79
+ mQCZAAAAAAAADgBQAGEAbABlACAARAB1AGwAbAAgAFIAZ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AAAAAAADwBMAGkAZwBoAHQAIABSAGUAZAAtAFAAaQBuAGsA
296
+ AAAAzAAAADMAAAAAAAAOAEQAYQByAGsAIABSAGUAZAAtAFAAaQBuAGsAAAAA
297
+ /wAAADMAAAAAAAANAFIAZQBkAC0AUgBlAGQALQBQAGkAbgBrAAA=
298
+ EOS
299
+
300
+ EXERCISE = <<-EOS
301
+ AAIABwAAHgA8AFoAAAAAAAAEAFIARwBCAAAAAQKPGZn//wAAAAAABABIAFMA
302
+ QgAAAAIMzH//GZn//wAAAAUAQwBNAFkASwAAAAcbWOiQG1gAAAAAAAQATABB
303
+ AEIAAAAIFXwAAAAAAAAAAAAFAEcAcgBhAHkAAAAJCcQNrBGUBdwAAAAGAFcA
304
+ QwBNAFkASwAAAA0JxA2sEZQF3AAAAAsAVQBOAEsATgBPAFcATgAgADEAMwAA
305
+ EOS
306
+ # http://www.visibone.com/swatches/VisiBone.aco
307
+ # http://www.visibone.com/swatches/VisiBone2.aco
308
+ # http://www.visibone.com/swatches/VisiBone2_km.psppalette
309
+ # http://www.visibone.com/swatches/VisiBone2_km.pal
310
+ # http://www.visibone.com/swatches/VisiBone2_vaccc.ai
311
+ # http://www.visibone.com/swatches/VisiBone.gimp
312
+ # http://www.visibone.com/swatches/VisiBone.act
313
+
314
+ def setup
315
+ @filename = "test#{Process.pid}.aco"
316
+ end
317
+
318
+ def teardown
319
+ require 'fileutils'
320
+ FileUtils.rm_f @filename if File.exist? @filename
321
+ end
322
+
323
+ def test_version1
324
+ v1 = VISIBONE_V1.unpack("m*")[0]
325
+ @aco = AdobeColorLib.new(v1)
326
+ assert_equal(216, @aco.size)
327
+ assert_equal(1, @aco.version)
328
+ assert_equal({ :rgb => 216 }, @aco.statistics)
329
+ assert_equal(ColorLib::RGB::White, @aco[0])
330
+ assert_equal("#ff0033", @aco[-1].html)
331
+ assert_equal(v1, @aco.to_aco)
332
+ end
333
+
334
+ def test_version2
335
+ v2 = VISIBONE_V2.unpack("m*")[0]
336
+ @aco = AdobeColorLib.new(v2)
337
+ assert_equal(216, @aco.size)
338
+ assert_equal(2, @aco.version)
339
+ assert_equal({ :rgb => 216 }, @aco.statistics)
340
+ assert_equal(ColorLib::RGB::White, @aco[0])
341
+ assert_equal(ColorLib::RGB::White,
342
+ @aco["\000W\000h\000i\000t\000e"][0])
343
+ assert_equal("#ff0033", @aco[-1].html)
344
+ assert_equal("#ff0033",
345
+ @aco["\000R\000e\000d\000-\000R\000e\000d\000-\000P\000i\000n\000k"][0].html)
346
+ assert_equal(v2, @aco.to_aco)
347
+ end
348
+
349
+ def test_bogus
350
+ o = VISIBONE_V2.unpack("m*")[0]
351
+ v = o.dup
352
+ v[0, 2] = [322].pack("n") # break the version
353
+ assert_raises(RuntimeError) { AdobeColorLib.new(v) }
354
+ v = o.dup
355
+ v[2, 2] = [217].pack("n") # break the colour count
356
+ assert_raises(IndexError) { @aco = AdobeColorLib.new(v) }
357
+ v = o.dup
358
+ v[14, 2] = [99].pack("n") # break the NULL before the name
359
+ assert_raises(IndexError) { @aco = AdobeColorLib.new(v) }
360
+ v = o.dup
361
+ v[16, 2] = [18].pack("n") # break the length of the name
362
+ assert_raises(IndexError) { @aco = AdobeColorLib.new(v) }
363
+ v = o.dup
364
+ v[28, 2] = [99].pack("n") # break the trailing null of the name
365
+ end
366
+
367
+ def test_exercise
368
+ File.open(@filename, "wb") do |f|
369
+ f.write EXERCISE.unpack("m*")[0]
370
+ end
371
+ @aco = AdobeColorLib.from_file(@filename)
372
+ assert_equal(5, @aco.size)
373
+ assert_equal(7, @aco.instance_variable_get(:@order).size)
374
+ end
375
+
376
+ def test_each
377
+ v1 = VISIBONE_V1.unpack("m*")[0]
378
+ @aco = AdobeColorLib.new(v1)
379
+ @aco.each { |c| assert_kind_of(ColorLib::RGB, c) }
380
+ end
381
+
382
+ def test_each_name
383
+ v2 = VISIBONE_V2.unpack("m*")[0]
384
+ @aco = AdobeColorLib.new(v2)
385
+ assert_equal(216, @aco.size)
386
+ assert_equal(2, @aco.version)
387
+ @aco.each_name do |n, s|
388
+ assert_equal(0, n[0]) if RUBY_VERSION < "1.9"
389
+ assert_equal(1, s.size)
390
+ assert_kind_of(ColorLib::RGB, s[0])
391
+ end
392
+ end
393
+
394
+ def test_values_at
395
+ v2 = VISIBONE_V2.unpack("m*")[0]
396
+ @aco = AdobeColorLib.new(v2)
397
+ assert_equal(216, @aco.size)
398
+ assert_equal(2, @aco.version)
399
+ assert_equal([ColorLib::RGB::White, ColorLib::RGB.from_html("#ff0033")],
400
+ @aco.values_at(0, -1))
401
+ end
402
+ end
403
+ end
404
+ end
data/test/test_cmyk.rb ADDED
@@ -0,0 +1,117 @@
1
+ require 'minitest/autorun'
2
+ require 'test/unit/assertions'
3
+ require 'color_lib'
4
+
5
+ module TestColorLib
6
+ class TestCMYK < Minitest::Test
7
+ include Test::Unit::Assertions
8
+
9
+ def setup
10
+ @cmyk = ColorLib::CMYK.new(10, 20, 30, 40)
11
+ end
12
+
13
+ def test_cyan
14
+ assert_in_delta(0.1, @cmyk.c, ColorLib::COLOR_TOLERANCE)
15
+ assert_in_delta(10, @cmyk.cyan, ColorLib::COLOR_TOLERANCE)
16
+ @cmyk.cyan = 20
17
+ assert_in_delta(0.2, @cmyk.c, ColorLib::COLOR_TOLERANCE)
18
+ @cmyk.c = 2.0
19
+ assert_in_delta(100, @cmyk.cyan, ColorLib::COLOR_TOLERANCE)
20
+ @cmyk.c = -1.0
21
+ assert_in_delta(0.0, @cmyk.c, ColorLib::COLOR_TOLERANCE)
22
+ end
23
+
24
+ def test_magenta
25
+ assert_in_delta(0.2, @cmyk.m, ColorLib::COLOR_TOLERANCE)
26
+ assert_in_delta(20, @cmyk.magenta, ColorLib::COLOR_TOLERANCE)
27
+ @cmyk.magenta = 30
28
+ assert_in_delta(0.3, @cmyk.m, ColorLib::COLOR_TOLERANCE)
29
+ @cmyk.m = 2.0
30
+ assert_in_delta(100, @cmyk.magenta, ColorLib::COLOR_TOLERANCE)
31
+ @cmyk.m = -1.0
32
+ assert_in_delta(0.0, @cmyk.m, ColorLib::COLOR_TOLERANCE)
33
+ end
34
+
35
+ def test_yellow
36
+ assert_in_delta(0.3, @cmyk.y, ColorLib::COLOR_TOLERANCE)
37
+ assert_in_delta(30, @cmyk.yellow, ColorLib::COLOR_TOLERANCE)
38
+ @cmyk.yellow = 20
39
+ assert_in_delta(0.2, @cmyk.y, ColorLib::COLOR_TOLERANCE)
40
+ @cmyk.y = 2.0
41
+ assert_in_delta(100, @cmyk.yellow, ColorLib::COLOR_TOLERANCE)
42
+ @cmyk.y = -1.0
43
+ assert_in_delta(0.0, @cmyk.y, ColorLib::COLOR_TOLERANCE)
44
+ end
45
+
46
+ def test_black
47
+ assert_in_delta(0.4, @cmyk.k, ColorLib::COLOR_TOLERANCE)
48
+ assert_in_delta(40, @cmyk.black, ColorLib::COLOR_TOLERANCE)
49
+ @cmyk.black = 20
50
+ assert_in_delta(0.2, @cmyk.k, ColorLib::COLOR_TOLERANCE)
51
+ @cmyk.k = 2.0
52
+ assert_in_delta(100, @cmyk.black, ColorLib::COLOR_TOLERANCE)
53
+ @cmyk.k = -1.0
54
+ assert_in_delta(0.0, @cmyk.k, ColorLib::COLOR_TOLERANCE)
55
+ end
56
+
57
+ def test_pdf
58
+ assert_equal("0.100 0.200 0.300 0.400 k", @cmyk.pdf_fill)
59
+ assert_equal("0.100 0.200 0.300 0.400 K", @cmyk.pdf_stroke)
60
+ end
61
+
62
+ def test_to_cmyk
63
+ assert(@cmyk.to_cmyk == @cmyk)
64
+ end
65
+
66
+ def test_to_grayscale
67
+ gs = nil
68
+ gs = @cmyk.to_grayscale
69
+ assert_kind_of(ColorLib::GrayScale, gs)
70
+ assert_in_delta(0.4185, gs.g, ColorLib::COLOR_TOLERANCE)
71
+ assert_kind_of(ColorLib::GreyScale, @cmyk.to_greyscale)
72
+ end
73
+
74
+ def test_to_hsl
75
+ hsl = nil
76
+ hsl = @cmyk.to_hsl
77
+ assert_kind_of(ColorLib::HSL, hsl)
78
+ assert_in_delta(0.48, hsl.l, ColorLib::COLOR_TOLERANCE)
79
+ assert_in_delta(0.125, hsl.s, ColorLib::COLOR_TOLERANCE)
80
+ assert_in_delta(0.08333, hsl.h, ColorLib::COLOR_TOLERANCE)
81
+ assert_equal("hsl(30.00, 12.50%, 48.00%)", @cmyk.css_hsl)
82
+ assert_equal("hsla(30.00, 12.50%, 48.00%, 1.00)", @cmyk.css_hsla)
83
+ end
84
+
85
+ def test_to_rgb
86
+ rgb = nil
87
+ rgb = @cmyk.to_rgb(true)
88
+ assert_kind_of(ColorLib::RGB, rgb)
89
+ assert_in_delta(0.5, rgb.r, ColorLib::COLOR_TOLERANCE)
90
+ assert_in_delta(0.4, rgb.g, ColorLib::COLOR_TOLERANCE)
91
+ assert_in_delta(0.3, rgb.b, ColorLib::COLOR_TOLERANCE)
92
+
93
+ rgb = @cmyk.to_rgb
94
+ assert_kind_of(ColorLib::RGB, rgb)
95
+ assert_in_delta(0.54, rgb.r, ColorLib::COLOR_TOLERANCE)
96
+ assert_in_delta(0.48, rgb.g, ColorLib::COLOR_TOLERANCE)
97
+ assert_in_delta(0.42, rgb.b, ColorLib::COLOR_TOLERANCE)
98
+
99
+ assert_equal("#8a7a6b", @cmyk.html)
100
+ assert_equal("rgb(54.00%, 48.00%, 42.00%)", @cmyk.css_rgb)
101
+ assert_equal("rgba(54.00%, 48.00%, 42.00%, 1.00)", @cmyk.css_rgba)
102
+ end
103
+
104
+ def test_inspect
105
+ assert_equal("CMYK [10.00%, 20.00%, 30.00%, 40.00%]", @cmyk.inspect)
106
+ end
107
+
108
+ def test_to_yiq
109
+ yiq = nil
110
+ yiq = @cmyk.to_yiq
111
+ assert_kind_of(ColorLib::YIQ, yiq)
112
+ assert_in_delta(0.4911, yiq.y, ColorLib::COLOR_TOLERANCE)
113
+ assert_in_delta(0.05502, yiq.i, ColorLib::COLOR_TOLERANCE)
114
+ assert_in_delta(0.0, yiq.q, ColorLib::COLOR_TOLERANCE)
115
+ end
116
+ end
117
+ end