spectrum 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,73 @@
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'
16
+ require 'spectrum'
17
+
18
+ module TestColor
19
+ class TestYIQ < Test::Unit::TestCase
20
+ def setup
21
+ @yiq = Spectrum::YIQ.from_fraction(0.1, 0.2, 0.3)
22
+ end
23
+
24
+ def test_brightness
25
+ assert_in_delta(0.1, @yiq.brightness, Spectrum::COLOR_TOLERANCE)
26
+ end
27
+
28
+ def test_i
29
+ assert_in_delta(0.2, @yiq.i, Spectrum::COLOR_TOLERANCE)
30
+ assert_in_delta(0.2, @yiq.i, Spectrum::COLOR_TOLERANCE)
31
+ assert_nothing_raised { @yiq.i = 0.5 }
32
+ assert_in_delta(0.5, @yiq.i, Spectrum::COLOR_TOLERANCE)
33
+ assert_nothing_raised { @yiq.i = 5 }
34
+ assert_in_delta(1.0, @yiq.i, Spectrum::COLOR_TOLERANCE)
35
+ assert_nothing_raised { @yiq.i = -5 }
36
+ assert_in_delta(0.0, @yiq.i, Spectrum::COLOR_TOLERANCE)
37
+ end
38
+
39
+ def test_q
40
+ assert_in_delta(0.3, @yiq.q, Spectrum::COLOR_TOLERANCE)
41
+ assert_in_delta(0.3, @yiq.q, Spectrum::COLOR_TOLERANCE)
42
+ assert_nothing_raised { @yiq.q = 0.5 }
43
+ assert_in_delta(0.5, @yiq.q, Spectrum::COLOR_TOLERANCE)
44
+ assert_nothing_raised { @yiq.q = 5 }
45
+ assert_in_delta(1.0, @yiq.q, Spectrum::COLOR_TOLERANCE)
46
+ assert_nothing_raised { @yiq.q = -5 }
47
+ assert_in_delta(0.0, @yiq.q, Spectrum::COLOR_TOLERANCE)
48
+ end
49
+
50
+ def test_to_grayscale
51
+ assert_equal(Spectrum::GrayScale.new(0.1), @yiq.to_grayscale)
52
+ end
53
+
54
+ def test_to_yiq
55
+ assert_equal(@yiq, @yiq.to_yiq)
56
+ end
57
+
58
+ def test_y
59
+ assert_in_delta(0.1, @yiq.y, Spectrum::COLOR_TOLERANCE)
60
+ assert_in_delta(0.1, @yiq.y, Spectrum::COLOR_TOLERANCE)
61
+ assert_nothing_raised { @yiq.y = 0.5 }
62
+ assert_in_delta(0.5, @yiq.y, Spectrum::COLOR_TOLERANCE)
63
+ assert_nothing_raised { @yiq.y = 5 }
64
+ assert_in_delta(1.0, @yiq.y, Spectrum::COLOR_TOLERANCE)
65
+ assert_nothing_raised { @yiq.y = -5 }
66
+ assert_in_delta(0.0, @yiq.y, Spectrum::COLOR_TOLERANCE)
67
+ end
68
+
69
+ def test_inspect
70
+ assert_equal("YIQ [10.00%, 20.00%, 30.00%]", @yiq.inspect)
71
+ end
72
+ end
73
+ end
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spectrum
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Austin Ziegler
9
+ - Matt Lyon
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2012-02-27 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: detroit
17
+ requirement: &12014640 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: *12014640
26
+ - !ruby/object:Gem::Dependency
27
+ name: mast
28
+ requirement: &12011760 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: *12011760
37
+ description: Color is a Ruby library to provide basic RGB, CMYK, HSL, and other colourspace
38
+ manipulation support to applications that require it. It also provides 152 named
39
+ RGB colours (184 with spelling variations) that are commonly supported in HTML,
40
+ SVG, and X11 applications. A technique for generating monochromatic contrasting
41
+ palettes is also included.
42
+ email:
43
+ - austin@rubyforge.org
44
+ - matt@postsomnia.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files:
48
+ - README.txt
49
+ - Install.txt
50
+ - Licence.txt
51
+ - History.txt
52
+ files:
53
+ - lib/spectrum/cmyk.rb
54
+ - lib/spectrum/css.rb
55
+ - lib/spectrum/grayscale.rb
56
+ - lib/spectrum/hsl.rb
57
+ - lib/spectrum/palette/adobecolor.rb
58
+ - lib/spectrum/palette/gimp.rb
59
+ - lib/spectrum/palette/monocontrast.rb
60
+ - lib/spectrum/palette.rb
61
+ - lib/spectrum/rgb/metallic.rb
62
+ - lib/spectrum/rgb-colors.rb
63
+ - lib/spectrum/rgb.rb
64
+ - lib/spectrum/yiq.rb
65
+ - lib/spectrum.rb
66
+ - test/test_adobecolor.rb
67
+ - test/test_all.rb
68
+ - test/test_cmyk.rb
69
+ - test/test_color.rb
70
+ - test/test_css.rb
71
+ - test/test_gimp.rb
72
+ - test/test_grayscale.rb
73
+ - test/test_hsl.rb
74
+ - test/test_monocontrast.rb
75
+ - test/test_rgb.rb
76
+ - test/test_yiq.rb
77
+ - README.txt
78
+ - Install.txt
79
+ - Licence.txt
80
+ - History.txt
81
+ homepage: http://rubyworks.github.com/spectrum
82
+ licenses:
83
+ - BSD-3-Clause
84
+ - BSD-3-Clause
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ! '>='
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 1.8.11
104
+ signing_key:
105
+ specification_version: 3
106
+ summary: Colour management with Ruby
107
+ test_files: []
108
+ has_rdoc: