coloryze 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,95 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'rubyunit'
5
+ require 'color/scheme'
6
+ require 'color/rgb'
7
+
8
+
9
+ class SchemeTestCase < RUNIT::TestCase
10
+
11
+ def do_create_hue_test(exp, val)
12
+ assert_equals exp, Color::Scheme.create_hue(val)
13
+ end
14
+
15
+ def test_create_hue
16
+ do_create_hue_test 0, 0
17
+ do_create_hue_test 70, 70
18
+ do_create_hue_test 17, 377
19
+ do_create_hue_test 122, 842
20
+ do_create_hue_test 70.1, "d4ff00"
21
+ end
22
+
23
+ def do_monochromatic_test(exp, val)
24
+ assert_equals [ exp ], Color::Monochromatic.new(val).hues
25
+ end
26
+
27
+ def test_monochromatic
28
+ do_monochromatic_test 0, 0
29
+ do_monochromatic_test 70, 70
30
+ do_monochromatic_test 17, 377
31
+ do_monochromatic_test 122, 842
32
+ do_monochromatic_test 70.1, "d4ff00"
33
+ end
34
+
35
+ def do_complementary_test(exp, val)
36
+ assert_equals exp, Color::Complementary.new(val).hues
37
+ end
38
+
39
+ def test_complementary
40
+ do_complementary_test [ 260, 80 ], 260
41
+ do_complementary_test [ 157, 337 ], 157
42
+ do_complementary_test [ 0, 180 ], 0
43
+ end
44
+
45
+ def do_split_complementary_test(exp, val, deg)
46
+ assert_equals exp, Color::SplitComplementary.new(val, deg).hues
47
+ end
48
+
49
+ def test_split_complementary
50
+ do_split_complementary_test [ 180, 4, 356 ], 180, 4
51
+ do_split_complementary_test [ 90, 300, 240 ], 90, 30
52
+ end
53
+
54
+ def do_double_complementary_test(exp, val0, val1)
55
+ assert_equals exp, Color::DoubleComplementary.new(val0, val1).hues
56
+ end
57
+
58
+ def test_double_complementary
59
+ do_double_complementary_test [ 0, 40, 180, 220 ], 0, 40
60
+ do_double_complementary_test [ 3, 313, 183, 133 ], 3, 313
61
+ end
62
+
63
+ def do_analogous_test(exp, val, deg)
64
+ assert_equals exp, Color::Analogous.new(val, deg).hues
65
+ end
66
+
67
+ def test_analogous
68
+ do_analogous_test [ 17, 7, 27 ], 17, 10
69
+ do_analogous_test [ 357, 337, 17 ], 357, 20
70
+ do_analogous_test [ 7, 353, 21 ], 7, 14
71
+ end
72
+
73
+ def do_triadic_test(exp, val)
74
+ assert_equals exp, Color::Triadic.new(val).hues
75
+ end
76
+
77
+ def test_triadic
78
+ do_triadic_test [ 60, 180, 300 ], 60
79
+ do_triadic_test [ 3, 123, 243 ], 3
80
+ do_triadic_test [ 331, 91, 211 ], 331
81
+ end
82
+
83
+ def do_hues_test(exp, startval, endval, interval)
84
+ assert_equals exp, Color::Hues.new(startval, endval, interval).hues
85
+ end
86
+
87
+ def test_hues(exp, startval, endval, interval)
88
+ do_hues_test [ 10, 20, 30, 40 ], 10, 40, 10
89
+ do_hues_test [ 10, 20, 30, 40 ], 10, 41, 10
90
+ do_hues_test [ 1, 2, 3, 4], 1, 4, 1
91
+ do_hues_test [ 311, 316, 321, 326, 331, 336], 311, 336, 5
92
+ end
93
+
94
+
95
+ end
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/ruby -w
2
+ # -*- ruby -*-
3
+
4
+ require 'rubyunit'
5
+ require 'color/hsb'
6
+ require 'color/rgb'
7
+ require 'color/sample_palette'
8
+ require 'stringio'
9
+
10
+
11
+ class UtilTestCase < RUNIT::TestCase
12
+
13
+ def test_distribution
14
+ assert_equals [ 3, 3 ], Color::distribution(6, 2)
15
+ assert_equals [ 3, 3, 2 ], Color::distribution(8, 3)
16
+ assert_equals [ 3, 3, 3 ], Color::distribution(9, 3)
17
+ assert_equals [ 2, 2, 2, 1, 1, 1, 1, 1 ], Color::distribution(11, 8)
18
+ assert_equals [ 50, 49 ], Color::distribution(99, 2)
19
+ end
20
+
21
+ # asserts that the number is within the values in ary, inclusive.
22
+ def assert_in_array(ary, num)
23
+ assert ary.include?(num), "#{num} in #{ary.inspect}"
24
+ end
25
+
26
+ def test_random_in_range
27
+ 25.times do
28
+ assert_in_array [ 1, 2, 3, 4 ], Color::random_in_range(1, 4, 1)
29
+ assert_in_array [ 2, 4, 6, 8 ], Color::random_in_range(2, 8, 2)
30
+ end
31
+ end
32
+
33
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: coloryze
3
+ version: !ruby/object:Gem::Version
4
+ hash: 15
5
+ prerelease: false
6
+ segments:
7
+ - 2
8
+ - 0
9
+ - 0
10
+ version: 2.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Jeff Pace
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-12-03 00:00:00 -05:00
19
+ default_executable: coloryze
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: riel
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 29
30
+ segments:
31
+ - 0
32
+ - 0
33
+ - 1
34
+ version: 0.0.1
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ description:
38
+ email: jpace@incava.org
39
+ executables:
40
+ - coloryze
41
+ extensions: []
42
+
43
+ extra_rdoc_files:
44
+ - README
45
+ files:
46
+ - bin/coloryze
47
+ - lib/color.rb
48
+ - lib/color/rgb.rb
49
+ - lib/color/coloryze.rb
50
+ - lib/color/scheme.rb
51
+ - lib/color/sample_palette.rb
52
+ - lib/color/hsb.rb
53
+ - lib/color/util.rb
54
+ - lib/color/full_palette.rb
55
+ - lib/color/palette.rb
56
+ - test/color/coloryze_test.rb
57
+ - test/color/scheme_test.rb
58
+ - test/color/hsb_test.rb
59
+ - test/color/sample_palette_test.rb
60
+ - test/color/rgb_test.rb
61
+ - test/color/full_palette_test.rb
62
+ - test/color/util_test.rb
63
+ - README
64
+ has_rdoc: true
65
+ homepage: http://www.incava.org/projects/coloryze
66
+ licenses: []
67
+
68
+ post_install_message:
69
+ rdoc_options: []
70
+
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ hash: 3
79
+ segments:
80
+ - 0
81
+ version: "0"
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ hash: 3
88
+ segments:
89
+ - 0
90
+ version: "0"
91
+ requirements: []
92
+
93
+ rubyforge_project:
94
+ rubygems_version: 1.3.7
95
+ signing_key:
96
+ specification_version: 3
97
+ summary: Generates colors based on schemes.
98
+ test_files:
99
+ - test/color/coloryze_test.rb
100
+ - test/color/scheme_test.rb
101
+ - test/color/hsb_test.rb
102
+ - test/color/sample_palette_test.rb
103
+ - test/color/rgb_test.rb
104
+ - test/color/full_palette_test.rb
105
+ - test/color/util_test.rb