timocratic-color 1.4.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,421 @@
1
+ #!/usr/bin/env ruby
2
+ #--
3
+ # Color
4
+ # Colour management with Ruby
5
+ # http://rubyforge.org/projects/color
6
+ # Version 1.4.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 - 2007 Austin Ziegler and Matt Lyon
12
+ #
13
+ # $Id: test_all.rb 55 2007-02-03 23:29:34Z austin $
14
+ #++
15
+
16
+ $LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../lib") if __FILE__ == $0
17
+ require 'test/unit'
18
+ require 'color'
19
+ require 'color/palette/adobecolor'
20
+
21
+ module TestColor
22
+ module TestPalette
23
+ class TestAdobeColor < Test::Unit::TestCase
24
+ include Color::Palette
25
+
26
+ # This is based on the Visibone Anglo-Centric Color Code List; this is
27
+ # an Adobe Color swatch version 1 (RGB colours only).
28
+ VISIBONE_V1 = <<-EOS
29
+ AAEA2AAA/wD/AP8AAAAAAMwAzADMAAAAAACZAJkAmQAAAAAAZgBmAGYAAAAA
30
+ ADMAMwAzAAAAAAAAAAAAAAAAAAAA/wAAAAAAAAAAAP8AMwAzAAAAAADMAAAA
31
+ AAAAAAAA/wBmAGYAAAAAAMwAMwAzAAAAAACZAAAAAAAAAAAA/wCZAJkAAAAA
32
+ AMwAZgBmAAAAAACZADMAMwAAAAAAZgAAAAAAAAAAAP8AzADMAAAAAADMAJkA
33
+ mQAAAAAAmQBmAGYAAAAAAGYAMwAzAAAAAAAzAAAAAAAAAAAA/wAzAAAAAAAA
34
+ AP8AZgAzAAAAAADMADMAAAAAAAAA/wCZAGYAAAAAAMwAZgAzAAAAAACZADMA
35
+ AAAAAAAA/wBmAAAAAAAAAP8AmQAzAAAAAADMAGYAAAAAAAAA/wDMAJkAAAAA
36
+ AMwAmQBmAAAAAACZAGYAMwAAAAAAZgAzAAAAAAAAAP8AmQAAAAAAAAD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AAAAAAP8AAAD/AAAAAAD/ADMA/wAAAAAAzAAAAMwAAAAA
70
+ AP8AZgD/AAAAAADMADMAzAAAAAAAmQAAAJkAAAAAAP8AmQD/AAAAAADMAGYA
71
+ zAAAAAAAmQAzAJkAAAAAAGYAAABmAAAAAAD/AMwA/wAAAAAAzACZAMwAAAAA
72
+ AJkAZgCZAAAAAABmADMAZgAAAAAAMwAAADMAAAAAAP8AAADMAAAAAAD/ADMA
73
+ zAAAAAAAzAAAAJkAAAAAAP8AZgDMAAAAAADMADMAmQAAAAAAmQAAAGYAAAAA
74
+ AP8AAACZAAAAAAD/ADMAmQAAAAAAzAAAAGYAAAAAAP8AmQDMAAAAAADMAGYA
75
+ mQAAAAAAmQAzAGYAAAAAAGYAAAAzAAAAAAD/AAAAZgAAAAAA/wBmAJkAAAAA
76
+ AMwAMwBmAAAAAACZAAAAMwAAAAAA/wAzAGYAAAAAAMwAAAAzAAAAAAD/AAAA
77
+ MwAAAA==
78
+ EOS
79
+
80
+ # This is based on the Visibone Anglo-Centric Color Code List; this is
81
+ # an Adobe Color swatch version 2 (with names).
82
+ VISIBONE_V2 = <<-EOS
83
+ AAIA2AAA/wD/AP8AAAAAAAAGAFcAaABpAHQAZQAAAADMAMwAzAAAAAAAAAoA
84
+ UABhAGwAZQAgAEcAcgBhAHkAAAAAmQCZAJkAAAAAAAALAEwAaQBnAGgAdAAg
85
+ AEcAcgBhAHkAAAAAZgBmAGYAAAAAAAAKAEQAYQByAGsAIABHAHIAYQB5AAAA
86
+ ADMAMwAzAAAAAAAADQBPAGIAcwBjAHUAcgBlACAARwByAGEAeQAAAAAAAAAA
87
+ AAAAAAAAAAYAQgBsAGEAYwBrAAAAAP8AAAAAAAAAAAAABABSAGUAZAAAAAD/
88
+ ADMAMwAAAAAAAA8ATABpAGcAaAB0ACAASABhAHIAZAAgAFIAZQBkAAAAAMwA
89
+ AAAAAAAAAAAADgBEAGEAcgBrACAASABhAHIAZAAgAFIAZQBkAAAAAP8AZgBm
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gBrAC0AUABpAG4AawAtAFIA
306
+ ZQBkAAAAAP8AZgCZAAAAAAAADwBMAGkAZwBoAHQAIABQAGkAbgBrAC0AUgBl
307
+ AGQAAAAAzAAzAGYAAAAAAAAQAE0AZQBkAGkAdQBtACAAUABpAG4AawAtAFIA
308
+ ZQBkAAAAAJkAAAAzAAAAAAAADgBEAGEAcgBrACAAUABpAG4AawAtAFIAZQBk
309
+ AAAAAP8AMwBmAAAAAAAADwBMAGkAZwBoAHQAIABSAGUAZAAtAFAAaQBuAGsA
310
+ AAAAzAAAADMAAAAAAAAOAEQAYQByAGsAIABSAGUAZAAtAFAAaQBuAGsAAAAA
311
+ /wAAADMAAAAAAAANAFIAZQBkAC0AUgBlAGQALQBQAGkAbgBrAAA=
312
+ EOS
313
+
314
+ EXERCISE = <<-EOS
315
+ AAIABwAAHgA8AFoAAAAAAAAEAFIARwBCAAAAAQKPGZn//wAAAAAABABIAFMA
316
+ QgAAAAIMzH//GZn//wAAAAUAQwBNAFkASwAAAAcbWOiQG1gAAAAAAAQATABB
317
+ AEIAAAAIFXwAAAAAAAAAAAAFAEcAcgBhAHkAAAAJCcQNrBGUBdwAAAAGAFcA
318
+ QwBNAFkASwAAAA0JxA2sEZQF3AAAAAsAVQBOAEsATgBPAFcATgAgADEAMwAA
319
+ EOS
320
+
321
+ # http://www.visibone.com/swatches/VisiBone.aco
322
+ # http://www.visibone.com/swatches/VisiBone2.aco
323
+ # http://www.visibone.com/swatches/VisiBone2_km.psppalette
324
+ # http://www.visibone.com/swatches/VisiBone2_km.pal
325
+ # http://www.visibone.com/swatches/VisiBone2_vaccc.ai
326
+ # http://www.visibone.com/swatches/VisiBone.gimp
327
+ # http://www.visibone.com/swatches/VisiBone.act
328
+
329
+ def setup
330
+ @filename = "test#{Process.pid}.aco"
331
+ end
332
+
333
+ def teardown
334
+ require 'fileutils'
335
+ FileUtils.rm_f @filename if File.exist? @filename
336
+ end
337
+
338
+ def test_version1
339
+ v1 = VISIBONE_V1.unpack("m*")[0]
340
+ assert_nothing_raised { @aco = AdobeColor.new(v1) }
341
+ assert_equal(216, @aco.size)
342
+ assert_equal(1, @aco.version)
343
+ assert_equal({:rgb => 216}, @aco.statistics)
344
+ assert_equal(Color::RGB::White, @aco[0])
345
+ assert_equal("#ff0033", @aco[-1].html)
346
+ assert_equal(v1, @aco.to_aco)
347
+ end
348
+
349
+ def test_version2
350
+ v2 = VISIBONE_V2.unpack("m*")[0]
351
+ @aco = AdobeColor.new(v2)
352
+ assert_equal(216, @aco.size)
353
+ assert_equal(2, @aco.version)
354
+ assert_equal({:rgb => 216}, @aco.statistics)
355
+ assert_equal(Color::RGB::White, @aco[0])
356
+ assert_equal(Color::RGB::White,
357
+ @aco["\000W\000h\000i\000t\000e"][0])
358
+ assert_equal("#ff0033", @aco[-1].html)
359
+ assert_equal("#ff0033",
360
+ @aco["\000R\000e\000d\000-\000R\000e\000d\000-\000P\000i\000n\000k"][0].html)
361
+ assert_equal(v2, @aco.to_aco)
362
+ end
363
+
364
+ def test_bogus
365
+ o = VISIBONE_V2.unpack("m*")[0]
366
+ v = o.dup
367
+ v[0, 2] = [ 322 ].pack("n") # break the version
368
+ assert_raises(RuntimeError) { AdobeColor.new(v) }
369
+ v = o.dup
370
+ v[2, 2] = [ 217 ].pack("n") # break the colour count
371
+ assert_raises(IndexError) { @aco = AdobeColor.new(v) }
372
+ v = o.dup
373
+ v[14, 2] = [ 99 ].pack("n") # break the NULL before the name
374
+ assert_raises(IndexError) { @aco = AdobeColor.new(v) }
375
+ v = o.dup
376
+ v[16, 2] = [ 18 ].pack("n") # break the length of the name
377
+ assert_raises(IndexError) { @aco = AdobeColor.new(v) }
378
+ v = o.dup
379
+ v[28, 2] = [ 99 ].pack("n") # break the trailing null of the name
380
+ end
381
+
382
+ def test_exercise
383
+ assert_nothing_raised do
384
+ File.open(@filename, "wb") do |f|
385
+ f.write EXERCISE.unpack("m*")[0]
386
+ end
387
+ end
388
+ assert_nothing_raised { @aco = AdobeColor.from_file(@filename) }
389
+ assert_equal(5, @aco.size)
390
+ assert_equal(7, @aco.instance_variable_get(:@order).size)
391
+ end
392
+
393
+ def test_each
394
+ v1 = VISIBONE_V1.unpack("m*")[0]
395
+ @aco = AdobeColor.new(v1)
396
+ @aco.each { |c| assert_kind_of(Color::RGB, c) }
397
+ end
398
+
399
+ def test_each_name
400
+ v2 = VISIBONE_V2.unpack("m*")[0]
401
+ assert_nothing_raised { @aco = AdobeColor.new(v2) }
402
+ assert_equal(216, @aco.size)
403
+ assert_equal(2, @aco.version)
404
+ @aco.each_name do |n, s|
405
+ assert_equal(0, n[0]) if RUBY_VERSION < "1.9"
406
+ assert_equal(1, s.size)
407
+ assert_kind_of(Color::RGB, s[0])
408
+ end
409
+ end
410
+
411
+ def test_values_at
412
+ v2 = VISIBONE_V2.unpack("m*")[0]
413
+ assert_nothing_raised { @aco = AdobeColor.new(v2) }
414
+ assert_equal(216, @aco.size)
415
+ assert_equal(2, @aco.version)
416
+ assert_equal([Color::RGB::White, Color::RGB.from_html("#ff0033")],
417
+ @aco.values_at(0, -1))
418
+ end
419
+ end
420
+ end
421
+ end
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+ #--
3
+ # Color
4
+ # Colour management with Ruby
5
+ # http://rubyforge.org/projects/color
6
+ # Version 1.4.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 - 2007 Austin Ziegler and Matt Lyon
12
+ #
13
+ # $Id: test_all.rb 55 2007-02-03 23:29:34Z austin $
14
+ #++
15
+
16
+ $LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../lib") if __FILE__ == $0
17
+
18
+ $stderr.puts "Checking for test cases:"
19
+
20
+ Dir[File.join(File.dirname($0), 'test_*.rb')].each do |testcase|
21
+ next if File.basename(testcase) == File.basename(__FILE__)
22
+ $stderr.puts "\t#{testcase}"
23
+ load testcase
24
+ end
25
+ $stderr.puts " "
@@ -0,0 +1,130 @@
1
+ #!/usr/bin/env ruby
2
+ #--
3
+ # Color
4
+ # Colour management with Ruby
5
+ # http://rubyforge.org/projects/color
6
+ # Version 1.4.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 - 2007 Austin Ziegler and Matt Lyon
12
+ #
13
+ # $Id: test_all.rb 55 2007-02-03 23:29:34Z austin $
14
+ #++
15
+
16
+ $LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../lib") if __FILE__ == $0
17
+ require 'test/unit'
18
+ require 'color'
19
+
20
+ module TestColor
21
+ class TestCMYK < Test::Unit::TestCase
22
+ def setup
23
+ @cmyk = Color::CMYK.new(10, 20, 30, 40)
24
+ end
25
+
26
+ def test_cyan
27
+ assert_in_delta(0.1, @cmyk.c, Color::COLOR_TOLERANCE)
28
+ assert_in_delta(10, @cmyk.cyan, Color::COLOR_TOLERANCE)
29
+ assert_nothing_raised { @cmyk.cyan = 20 }
30
+ assert_in_delta(0.2, @cmyk.c, Color::COLOR_TOLERANCE)
31
+ assert_nothing_raised { @cmyk.c = 2.0 }
32
+ assert_in_delta(100, @cmyk.cyan, Color::COLOR_TOLERANCE)
33
+ assert_nothing_raised { @cmyk.c = -1.0 }
34
+ assert_in_delta(0.0, @cmyk.c, Color::COLOR_TOLERANCE)
35
+ end
36
+
37
+ def test_magenta
38
+ assert_in_delta(0.2, @cmyk.m, Color::COLOR_TOLERANCE)
39
+ assert_in_delta(20, @cmyk.magenta, Color::COLOR_TOLERANCE)
40
+ assert_nothing_raised { @cmyk.magenta = 30 }
41
+ assert_in_delta(0.3, @cmyk.m, Color::COLOR_TOLERANCE)
42
+ assert_nothing_raised { @cmyk.m = 2.0 }
43
+ assert_in_delta(100, @cmyk.magenta, Color::COLOR_TOLERANCE)
44
+ assert_nothing_raised { @cmyk.m = -1.0 }
45
+ assert_in_delta(0.0, @cmyk.m, Color::COLOR_TOLERANCE)
46
+ end
47
+
48
+ def test_yellow
49
+ assert_in_delta(0.3, @cmyk.y, Color::COLOR_TOLERANCE)
50
+ assert_in_delta(30, @cmyk.yellow, Color::COLOR_TOLERANCE)
51
+ assert_nothing_raised { @cmyk.yellow = 20 }
52
+ assert_in_delta(0.2, @cmyk.y, Color::COLOR_TOLERANCE)
53
+ assert_nothing_raised { @cmyk.y = 2.0 }
54
+ assert_in_delta(100, @cmyk.yellow, Color::COLOR_TOLERANCE)
55
+ assert_nothing_raised { @cmyk.y = -1.0 }
56
+ assert_in_delta(0.0, @cmyk.y, Color::COLOR_TOLERANCE)
57
+ end
58
+
59
+ def test_black
60
+ assert_in_delta(0.4, @cmyk.k, Color::COLOR_TOLERANCE)
61
+ assert_in_delta(40, @cmyk.black, Color::COLOR_TOLERANCE)
62
+ assert_nothing_raised { @cmyk.black = 20 }
63
+ assert_in_delta(0.2, @cmyk.k, Color::COLOR_TOLERANCE)
64
+ assert_nothing_raised { @cmyk.k = 2.0 }
65
+ assert_in_delta(100, @cmyk.black, Color::COLOR_TOLERANCE)
66
+ assert_nothing_raised { @cmyk.k = -1.0 }
67
+ assert_in_delta(0.0, @cmyk.k, Color::COLOR_TOLERANCE)
68
+ end
69
+
70
+ def test_pdf
71
+ assert_equal("0.100 0.200 0.300 0.400 k", @cmyk.pdf_fill)
72
+ assert_equal("0.100 0.200 0.300 0.400 K", @cmyk.pdf_stroke)
73
+ end
74
+
75
+ def test_to_cmyk
76
+ assert(@cmyk.to_cmyk == @cmyk)
77
+ end
78
+
79
+ def test_to_grayscale
80
+ gs = nil
81
+ assert_nothing_raised { gs = @cmyk.to_grayscale }
82
+ assert_kind_of(Color::GrayScale, gs)
83
+ assert_in_delta(0.4185, gs.g, Color::COLOR_TOLERANCE)
84
+ assert_kind_of(Color::GreyScale, @cmyk.to_greyscale)
85
+ end
86
+
87
+ def test_to_hsl
88
+ hsl = nil
89
+ assert_nothing_raised { hsl = @cmyk.to_hsl }
90
+ assert_kind_of(Color::HSL, hsl)
91
+ assert_in_delta(0.48, hsl.l, Color::COLOR_TOLERANCE)
92
+ assert_in_delta(0.125, hsl.s, Color::COLOR_TOLERANCE)
93
+ assert_in_delta(0.08333, hsl.h, Color::COLOR_TOLERANCE)
94
+ assert_equal("hsl(30.00, 12.50%, 48.00%)", @cmyk.css_hsl)
95
+ assert_equal("hsla(30.00, 12.50%, 48.00%, 1.00)", @cmyk.css_hsla)
96
+ end
97
+
98
+ def test_to_rgb
99
+ rgb = nil
100
+ assert_nothing_raised { rgb = @cmyk.to_rgb(true) }
101
+ assert_kind_of(Color::RGB, rgb)
102
+ assert_in_delta(0.5, rgb.r, Color::COLOR_TOLERANCE)
103
+ assert_in_delta(0.4, rgb.g, Color::COLOR_TOLERANCE)
104
+ assert_in_delta(0.3, rgb.b, Color::COLOR_TOLERANCE)
105
+
106
+ assert_nothing_raised { rgb = @cmyk.to_rgb }
107
+ assert_kind_of(Color::RGB, rgb)
108
+ assert_in_delta(0.54, rgb.r, Color::COLOR_TOLERANCE)
109
+ assert_in_delta(0.48, rgb.g, Color::COLOR_TOLERANCE)
110
+ assert_in_delta(0.42, rgb.b, Color::COLOR_TOLERANCE)
111
+
112
+ assert_equal("#8a7a6b", @cmyk.html)
113
+ assert_equal("rgb(54.00%, 48.00%, 42.00%)", @cmyk.css_rgb)
114
+ assert_equal("rgba(54.00%, 48.00%, 42.00%, 1.00)", @cmyk.css_rgba)
115
+ end
116
+
117
+ def test_inspect
118
+ assert_equal("CMYK [10.00%, 20.00%, 30.00%, 40.00%]", @cmyk.inspect)
119
+ end
120
+
121
+ def test_to_yiq
122
+ yiq = nil
123
+ assert_nothing_raised { yiq = @cmyk.to_yiq }
124
+ assert_kind_of(Color::YIQ, yiq)
125
+ assert_in_delta(0.4911, yiq.y, Color::COLOR_TOLERANCE)
126
+ assert_in_delta(0.05502, yiq.i, Color::COLOR_TOLERANCE)
127
+ assert_in_delta(0.0, yiq.q, Color::COLOR_TOLERANCE)
128
+ end
129
+ end
130
+ end