color 1.4.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,15 +1,3 @@
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
1
  # An HSL colour object. Internally, the hue (#h), saturation (#s), and
14
2
  # luminosity/lightness (#l) values are dealt with as fractional values in
15
3
  # the range 0..1.
@@ -1,15 +1,3 @@
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
1
  require 'color'
14
2
 
15
3
  module Color::Palette
@@ -1,15 +1,3 @@
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
1
  require 'color/palette'
14
2
 
15
3
  # A class that can read an Adobe Color palette file (used for Photoshop
@@ -1,15 +1,3 @@
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
1
  require 'color/palette'
14
2
 
15
3
  # A class that can read a GIMP (GNU Image Manipulation Program) palette file
@@ -1,15 +1,3 @@
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
1
  require 'color/palette'
14
2
 
15
3
  # Generates a monochromatic constrasting colour palette for background and
@@ -25,7 +13,7 @@ require 'color/palette'
25
13
  # against the background.
26
14
  class Color::Palette::MonoContrast
27
15
  # Hash of CSS background colour values.
28
- #
16
+ #
29
17
  # This is always 11 values:
30
18
  #
31
19
  # 0:: The starting colour.
@@ -33,7 +21,7 @@ class Color::Palette::MonoContrast
33
21
  # -1..-5:: Darker colours.
34
22
  attr_reader :background
35
23
  # Hash of CSS foreground colour values.
36
- #
24
+ #
37
25
  # This is always 11 values:
38
26
  #
39
27
  # 0:: The starting colour.
@@ -60,7 +48,7 @@ class Color::Palette::MonoContrast
60
48
  else
61
49
  @minimum_brightness_diff = bd
62
50
  end
63
-
51
+
64
52
  regenerate(@background[0], @foreground[0])
65
53
  end
66
54
 
@@ -1,15 +1,3 @@
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
1
  class Color::RGB
14
2
  AliceBlue = Color::RGB.new(0xf0, 0xf8, 0xff)
15
3
  AntiqueWhite = Color::RGB.new(0xfa, 0xeb, 0xd7)
@@ -1,15 +1,3 @@
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
1
  # An RGB colour object.
14
2
  class Color::RGB
15
3
  # The format of a DeviceRGB colour for PDF. In color-tools 2.0 this will
@@ -45,7 +33,7 @@ class Color::RGB
45
33
  # Color::RGB.from_html("cabbed")
46
34
  def from_html(html_colour)
47
35
  html_colour = html_colour.gsub(%r{[#;]}, '')
48
- case html_colour.size
36
+ case html_colour.size
49
37
  when 3
50
38
  colours = html_colour.scan(%r{[0-9A-Fa-f]}).map { |el| (el * 2).to_i(16) }
51
39
  when 6
@@ -249,7 +237,7 @@ class Color::RGB
249
237
  def mix_with(mask, opacity)
250
238
  opacity /= 100.0
251
239
  rgb = self.dup
252
-
240
+
253
241
  rgb.r = (@r * opacity) + (mask.r * (1 - opacity))
254
242
  rgb.g = (@g * opacity) + (mask.g * (1 - opacity))
255
243
  rgb.b = (@b * opacity) + (mask.b * (1 - opacity))
@@ -427,8 +415,8 @@ class Color::RGB
427
415
  #
428
416
  # The subtraction is done using the RGB Accessor methods to ensure a valid
429
417
  # colour in the result.
430
- def -(other)
431
- other = other.to_rgb
418
+ def -(other)
419
+ other = other.to_rgb
432
420
  rgb = self.dup
433
421
 
434
422
  rgb.r -= other.r
@@ -1,15 +1,3 @@
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
1
  # This namespace contains some RGB metallic colours suggested by Jim Freeze.
14
2
  module Color::RGB::Metallic
15
3
  Aluminum = Color::RGB.new(0x99, 0x99, 0x99)
@@ -1,15 +1,3 @@
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
1
  # A colour object representing YIQ (NTSC) colour encoding.
14
2
  class Color::YIQ
15
3
  # Creates a YIQ colour object from fractional values 0 .. 1.
@@ -44,7 +32,7 @@ class Color::YIQ
44
32
  other.kind_of?(Color::YIQ) and
45
33
  ((@y - other.y).abs <= Color::COLOR_TOLERANCE) and
46
34
  ((@i - other.i).abs <= Color::COLOR_TOLERANCE) and
47
- ((@q - other.q).abs <= Color::COLOR_TOLERANCE)
35
+ ((@q - other.q).abs <= Color::COLOR_TOLERANCE)
48
36
  end
49
37
 
50
38
  def to_yiq
@@ -1,24 +1,12 @@
1
- #!/usr/bin/env ruby
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/adobecolor'
18
6
 
19
7
  module TestColor
20
8
  module TestPalette
21
- class TestAdobeColor < Test::Unit::TestCase
9
+ class TestAdobeColor < Minitest::Test
22
10
  include Color::Palette
23
11
 
24
12
  # This is based on the Visibone Anglo-Centric Color Code List; this is
@@ -335,7 +323,7 @@ QwBNAFkASwAAAA0JxA2sEZQF3AAAAAsAVQBOAEsATgBPAFcATgAgADEAMwAA
335
323
 
336
324
  def test_version1
337
325
  v1 = VISIBONE_V1.unpack("m*")[0]
338
- assert_nothing_raised { @aco = AdobeColor.new(v1) }
326
+ @aco = AdobeColor.new(v1)
339
327
  assert_equal(216, @aco.size)
340
328
  assert_equal(1, @aco.version)
341
329
  assert_equal({:rgb => 216}, @aco.statistics)
@@ -378,12 +366,10 @@ QwBNAFkASwAAAA0JxA2sEZQF3AAAAAsAVQBOAEsATgBPAFcATgAgADEAMwAA
378
366
  end
379
367
 
380
368
  def test_exercise
381
- assert_nothing_raised do
382
- File.open(@filename, "wb") do |f|
383
- f.write EXERCISE.unpack("m*")[0]
384
- end
369
+ File.open(@filename, "wb") do |f|
370
+ f.write EXERCISE.unpack("m*")[0]
385
371
  end
386
- assert_nothing_raised { @aco = AdobeColor.from_file(@filename) }
372
+ @aco = AdobeColor.from_file(@filename)
387
373
  assert_equal(5, @aco.size)
388
374
  assert_equal(7, @aco.instance_variable_get(:@order).size)
389
375
  end
@@ -396,7 +382,7 @@ QwBNAFkASwAAAA0JxA2sEZQF3AAAAAsAVQBOAEsATgBPAFcATgAgADEAMwAA
396
382
 
397
383
  def test_each_name
398
384
  v2 = VISIBONE_V2.unpack("m*")[0]
399
- assert_nothing_raised { @aco = AdobeColor.new(v2) }
385
+ @aco = AdobeColor.new(v2)
400
386
  assert_equal(216, @aco.size)
401
387
  assert_equal(2, @aco.version)
402
388
  @aco.each_name do |n, s|
@@ -408,7 +394,7 @@ QwBNAFkASwAAAA0JxA2sEZQF3AAAAAsAVQBOAEsATgBPAFcATgAgADEAMwAA
408
394
 
409
395
  def test_values_at
410
396
  v2 = VISIBONE_V2.unpack("m*")[0]
411
- assert_nothing_raised { @aco = AdobeColor.new(v2) }
397
+ @aco = AdobeColor.new(v2)
412
398
  assert_equal(216, @aco.size)
413
399
  assert_equal(2, @aco.version)
414
400
  assert_equal([Color::RGB::White, Color::RGB.from_html("#ff0033")],
@@ -1,22 +1,10 @@
1
- #!/usr/bin/env ruby
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 TestCMYK < Test::Unit::TestCase
7
+ class TestCMYK < Minitest::Test
20
8
  def setup
21
9
  @cmyk = Color::CMYK.new(10, 20, 30, 40)
22
10
  end
@@ -24,44 +12,44 @@ module TestColor
24
12
  def test_cyan
25
13
  assert_in_delta(0.1, @cmyk.c, Color::COLOR_TOLERANCE)
26
14
  assert_in_delta(10, @cmyk.cyan, Color::COLOR_TOLERANCE)
27
- assert_nothing_raised { @cmyk.cyan = 20 }
15
+ @cmyk.cyan = 20
28
16
  assert_in_delta(0.2, @cmyk.c, Color::COLOR_TOLERANCE)
29
- assert_nothing_raised { @cmyk.c = 2.0 }
17
+ @cmyk.c = 2.0
30
18
  assert_in_delta(100, @cmyk.cyan, Color::COLOR_TOLERANCE)
31
- assert_nothing_raised { @cmyk.c = -1.0 }
19
+ @cmyk.c = -1.0
32
20
  assert_in_delta(0.0, @cmyk.c, Color::COLOR_TOLERANCE)
33
21
  end
34
22
 
35
23
  def test_magenta
36
24
  assert_in_delta(0.2, @cmyk.m, Color::COLOR_TOLERANCE)
37
25
  assert_in_delta(20, @cmyk.magenta, Color::COLOR_TOLERANCE)
38
- assert_nothing_raised { @cmyk.magenta = 30 }
26
+ @cmyk.magenta = 30
39
27
  assert_in_delta(0.3, @cmyk.m, Color::COLOR_TOLERANCE)
40
- assert_nothing_raised { @cmyk.m = 2.0 }
28
+ @cmyk.m = 2.0
41
29
  assert_in_delta(100, @cmyk.magenta, Color::COLOR_TOLERANCE)
42
- assert_nothing_raised { @cmyk.m = -1.0 }
30
+ @cmyk.m = -1.0
43
31
  assert_in_delta(0.0, @cmyk.m, Color::COLOR_TOLERANCE)
44
32
  end
45
33
 
46
34
  def test_yellow
47
35
  assert_in_delta(0.3, @cmyk.y, Color::COLOR_TOLERANCE)
48
36
  assert_in_delta(30, @cmyk.yellow, Color::COLOR_TOLERANCE)
49
- assert_nothing_raised { @cmyk.yellow = 20 }
37
+ @cmyk.yellow = 20
50
38
  assert_in_delta(0.2, @cmyk.y, Color::COLOR_TOLERANCE)
51
- assert_nothing_raised { @cmyk.y = 2.0 }
39
+ @cmyk.y = 2.0
52
40
  assert_in_delta(100, @cmyk.yellow, Color::COLOR_TOLERANCE)
53
- assert_nothing_raised { @cmyk.y = -1.0 }
41
+ @cmyk.y = -1.0
54
42
  assert_in_delta(0.0, @cmyk.y, Color::COLOR_TOLERANCE)
55
43
  end
56
44
 
57
45
  def test_black
58
46
  assert_in_delta(0.4, @cmyk.k, Color::COLOR_TOLERANCE)
59
47
  assert_in_delta(40, @cmyk.black, Color::COLOR_TOLERANCE)
60
- assert_nothing_raised { @cmyk.black = 20 }
48
+ @cmyk.black = 20
61
49
  assert_in_delta(0.2, @cmyk.k, Color::COLOR_TOLERANCE)
62
- assert_nothing_raised { @cmyk.k = 2.0 }
50
+ @cmyk.k = 2.0
63
51
  assert_in_delta(100, @cmyk.black, Color::COLOR_TOLERANCE)
64
- assert_nothing_raised { @cmyk.k = -1.0 }
52
+ @cmyk.k = -1.0
65
53
  assert_in_delta(0.0, @cmyk.k, Color::COLOR_TOLERANCE)
66
54
  end
67
55
 
@@ -75,16 +63,14 @@ module TestColor
75
63
  end
76
64
 
77
65
  def test_to_grayscale
78
- gs = nil
79
- assert_nothing_raised { gs = @cmyk.to_grayscale }
66
+ gs = @cmyk.to_grayscale
80
67
  assert_kind_of(Color::GrayScale, gs)
81
68
  assert_in_delta(0.4185, gs.g, Color::COLOR_TOLERANCE)
82
69
  assert_kind_of(Color::GreyScale, @cmyk.to_greyscale)
83
70
  end
84
71
 
85
72
  def test_to_hsl
86
- hsl = nil
87
- assert_nothing_raised { hsl = @cmyk.to_hsl }
73
+ hsl = @cmyk.to_hsl
88
74
  assert_kind_of(Color::HSL, hsl)
89
75
  assert_in_delta(0.48, hsl.l, Color::COLOR_TOLERANCE)
90
76
  assert_in_delta(0.125, hsl.s, Color::COLOR_TOLERANCE)
@@ -94,14 +80,13 @@ module TestColor
94
80
  end
95
81
 
96
82
  def test_to_rgb
97
- rgb = nil
98
- assert_nothing_raised { rgb = @cmyk.to_rgb(true) }
83
+ rgb = @cmyk.to_rgb(true)
99
84
  assert_kind_of(Color::RGB, rgb)
100
85
  assert_in_delta(0.5, rgb.r, Color::COLOR_TOLERANCE)
101
86
  assert_in_delta(0.4, rgb.g, Color::COLOR_TOLERANCE)
102
87
  assert_in_delta(0.3, rgb.b, Color::COLOR_TOLERANCE)
103
88
 
104
- assert_nothing_raised { rgb = @cmyk.to_rgb }
89
+ rgb = @cmyk.to_rgb
105
90
  assert_kind_of(Color::RGB, rgb)
106
91
  assert_in_delta(0.54, rgb.r, Color::COLOR_TOLERANCE)
107
92
  assert_in_delta(0.48, rgb.g, Color::COLOR_TOLERANCE)
@@ -117,8 +102,7 @@ module TestColor
117
102
  end
118
103
 
119
104
  def test_to_yiq
120
- yiq = nil
121
- assert_nothing_raised { yiq = @cmyk.to_yiq }
105
+ yiq = @cmyk.to_yiq
122
106
  assert_kind_of(Color::YIQ, yiq)
123
107
  assert_in_delta(0.4911, yiq.y, Color::COLOR_TOLERANCE)
124
108
  assert_in_delta(0.05502, yiq.i, Color::COLOR_TOLERANCE)
@@ -1,23 +1,11 @@
1
- #!/usr/bin/env ruby
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
-
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
  require 'color/css'
18
6
 
19
7
  module TestColor
20
- class TestColor < Test::Unit::TestCase
8
+ class TestColor < Minitest::Test
21
9
  def setup
22
10
  Kernel.module_eval do
23
11
  alias old_warn warn
@@ -1,23 +1,11 @@
1
- #!/usr/bin/env ruby
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/css'
18
6
 
19
7
  module TestColor
20
- class TestCSS < Test::Unit::TestCase
8
+ class TestCSS < Minitest::Test
21
9
  def test_index
22
10
  assert_equal(Color::RGB::AliceBlue, Color::CSS[:aliceblue])
23
11
  assert_equal(Color::RGB::AliceBlue, Color::CSS["AliceBlue"])