ripta-color-tools 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Changelog +55 -0
- data/Install +18 -0
- data/README.rdoc +82 -0
- data/Rakefile +123 -0
- data/lib/color.rb +78 -0
- data/lib/color/cmyk.rb +185 -0
- data/lib/color/css.rb +27 -0
- data/lib/color/grayscale.rb +135 -0
- data/lib/color/hsl.rb +134 -0
- data/lib/color/palette.rb +18 -0
- data/lib/color/palette/gimp.rb +105 -0
- data/lib/color/palette/monocontrast.rb +178 -0
- data/lib/color/rgb-colors.rb +189 -0
- data/lib/color/rgb.rb +315 -0
- data/lib/color/rgb/metallic.rb +28 -0
- data/lib/color/yiq.rb +80 -0
- data/metaconfig +13 -0
- data/pre-setup.rb +55 -0
- data/setup.rb +1366 -0
- data/tests/test_cmyk.rb +116 -0
- data/tests/test_css.rb +28 -0
- data/tests/test_gimp.rb +79 -0
- data/tests/test_grayscale.rb +87 -0
- data/tests/test_hsl.rb +93 -0
- data/tests/test_monocontrast.rb +145 -0
- data/tests/test_rgb.rb +160 -0
- data/tests/test_yiq.rb +81 -0
- data/tests/testall.rb +20 -0
- metadata +84 -0
data/tests/test_rgb.rb
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#--
|
3
|
+
# Colour management with Ruby.
|
4
|
+
#
|
5
|
+
# Copyright 2005 Austin Ziegler
|
6
|
+
# http://rubyforge.org/ruby-pdf/
|
7
|
+
#
|
8
|
+
# Licensed under a MIT-style licence.
|
9
|
+
#
|
10
|
+
# $Id$
|
11
|
+
#++
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../lib") if __FILE__ == $0
|
14
|
+
require 'test/unit' unless defined? $ZENTEST and $ZENTEST
|
15
|
+
require 'color'
|
16
|
+
|
17
|
+
module TestColor
|
18
|
+
class TestRGB < Test::Unit::TestCase
|
19
|
+
def test_adjust_brightness
|
20
|
+
assert_equal("#1a1aff", Color::RGB::Blue.adjust_brightness(10).html)
|
21
|
+
assert_equal("#0000e6", Color::RGB::Blue.adjust_brightness(-10).html)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_adjust_hue
|
25
|
+
assert_equal("#6600ff", Color::RGB::Blue.adjust_hue(10).html)
|
26
|
+
assert_equal("#0066ff", Color::RGB::Blue.adjust_hue(-10).html)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_adjust_saturation
|
30
|
+
assert_equal("#ef9374",
|
31
|
+
Color::RGB::DarkSalmon.adjust_saturation(10).html)
|
32
|
+
assert_equal("#e39980",
|
33
|
+
Color::RGB::DarkSalmon.adjust_saturation(-10).html)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_b
|
37
|
+
assert_in_delta(1.0, Color::RGB::Blue.b, 1e-4)
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_b_equals
|
41
|
+
b = Color::RGB::Blue.dup
|
42
|
+
assert_in_delta(1.0, b.b, 1e-4)
|
43
|
+
assert_nothing_raised { b.b = 0.33 }
|
44
|
+
assert_in_delta(0.33, b.b, 1e-4)
|
45
|
+
assert_nothing_raised { b.b = 3.3 }
|
46
|
+
assert_in_delta(1.0, b.b, 1e-4)
|
47
|
+
assert_nothing_raised { b.b = -3.3 }
|
48
|
+
assert_in_delta(0.0, b.b, 1e-4)
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_brightness
|
52
|
+
assert_in_delta(0.0, Color::RGB::Black.brightness, 1e-4)
|
53
|
+
assert_in_delta(0.5, Color::RGB::Grey50.brightness, 1e-4)
|
54
|
+
assert_in_delta(1.0, Color::RGB::White.brightness, 1e-4)
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_darken_by
|
58
|
+
assert_in_delta(0.5, Color::RGB::Blue.darken_by(50).b, 1e-4)
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_g
|
62
|
+
assert_in_delta(1.0, Color::RGB::Lime.g, 1e-4)
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_g_equals
|
66
|
+
g = Color::RGB::Lime.dup
|
67
|
+
assert_in_delta(1.0, g.g, 1e-4)
|
68
|
+
assert_nothing_raised { g.g = 0.33 }
|
69
|
+
assert_in_delta(0.33, g.g, 1e-4)
|
70
|
+
assert_nothing_raised { g.g = 3.3 }
|
71
|
+
assert_in_delta(1.0, g.g, 1e-4)
|
72
|
+
assert_nothing_raised { g.g = -3.3 }
|
73
|
+
assert_in_delta(0.0, g.g, 1e-4)
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_html
|
77
|
+
assert_equal("#000000", Color::RGB::Black.html)
|
78
|
+
assert_equal("#0000ff", Color::RGB::Blue.html)
|
79
|
+
assert_equal("#00ff00", Color::RGB::Lime.html)
|
80
|
+
assert_equal("#ff0000", Color::RGB::Red.html)
|
81
|
+
assert_equal("#ffffff", Color::RGB::White.html)
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_lighten_by
|
85
|
+
assert_in_delta(1.0, Color::RGB::Blue.lighten_by(50).b, 1e-4)
|
86
|
+
assert_in_delta(0.5, Color::RGB::Blue.lighten_by(50).r, 1e-4)
|
87
|
+
assert_in_delta(0.5, Color::RGB::Blue.lighten_by(50).g, 1e-4)
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_mix_with
|
91
|
+
assert_in_delta(0.5, Color::RGB::Red.mix_with(Color::RGB::Blue, 50).r,
|
92
|
+
1e-4)
|
93
|
+
assert_in_delta(0.0, Color::RGB::Red.mix_with(Color::RGB::Blue, 50).g,
|
94
|
+
1e-4)
|
95
|
+
assert_in_delta(0.5, Color::RGB::Red.mix_with(Color::RGB::Blue, 50).b,
|
96
|
+
1e-4)
|
97
|
+
assert_in_delta(0.5, Color::RGB::Blue.mix_with(Color::RGB::Red, 50).r,
|
98
|
+
1e-4)
|
99
|
+
assert_in_delta(0.0, Color::RGB::Blue.mix_with(Color::RGB::Red, 50).g,
|
100
|
+
1e-4)
|
101
|
+
assert_in_delta(0.5, Color::RGB::Blue.mix_with(Color::RGB::Red, 50).b,
|
102
|
+
1e-4)
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_pdf_fill
|
106
|
+
assert_equal("0.000 0.000 0.000 rg", Color::RGB::Black.pdf_fill)
|
107
|
+
assert_equal("0.000 0.000 1.000 rg", Color::RGB::Blue.pdf_fill)
|
108
|
+
assert_equal("0.000 1.000 0.000 rg", Color::RGB::Lime.pdf_fill)
|
109
|
+
assert_equal("1.000 0.000 0.000 rg", Color::RGB::Red.pdf_fill)
|
110
|
+
assert_equal("1.000 1.000 1.000 rg", Color::RGB::White.pdf_fill)
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_pdf_stroke
|
114
|
+
assert_equal("0.000 0.000 0.000 RG", Color::RGB::Black.pdf_stroke)
|
115
|
+
assert_equal("0.000 0.000 1.000 RG", Color::RGB::Blue.pdf_stroke)
|
116
|
+
assert_equal("0.000 1.000 0.000 RG", Color::RGB::Lime.pdf_stroke)
|
117
|
+
assert_equal("1.000 0.000 0.000 RG", Color::RGB::Red.pdf_stroke)
|
118
|
+
assert_equal("1.000 1.000 1.000 RG", Color::RGB::White.pdf_stroke)
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_r
|
122
|
+
assert_in_delta(1.0, Color::RGB::Red.r, 1e-4)
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_r_equals
|
126
|
+
r = Color::RGB::Red.dup
|
127
|
+
assert_in_delta(1.0, r.r, 1e-4)
|
128
|
+
assert_nothing_raised { r.r = 0.33 }
|
129
|
+
assert_in_delta(0.33, r.r, 1e-4)
|
130
|
+
assert_nothing_raised { r.r = 3.3 }
|
131
|
+
assert_in_delta(1.0, r.r, 1e-4)
|
132
|
+
assert_nothing_raised { r.r = -3.3 }
|
133
|
+
assert_in_delta(0.0, r.r, 1e-4)
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_to_cmyk
|
137
|
+
assert_kind_of(Color::CMYK, Color::RGB::Black.to_cmyk)
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_to_grayscale
|
141
|
+
assert_kind_of(Color::GrayScale, Color::RGB::Black.to_grayscale)
|
142
|
+
end
|
143
|
+
|
144
|
+
def test_to_greyscale
|
145
|
+
assert_kind_of(Color::GreyScale, Color::RGB::Black.to_greyscale)
|
146
|
+
end
|
147
|
+
|
148
|
+
def test_to_hsl
|
149
|
+
assert_kind_of(Color::HSL, Color::RGB::Black.to_hsl)
|
150
|
+
end
|
151
|
+
|
152
|
+
def test_to_rgb
|
153
|
+
assert_equal(Color::RGB::Black, Color::RGB::Black.to_rgb)
|
154
|
+
end
|
155
|
+
|
156
|
+
def test_to_yiq
|
157
|
+
assert_kind_of(Color::YIQ, Color::RGB::Black.to_yiq)
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
data/tests/test_yiq.rb
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#--
|
3
|
+
# Colour management with Ruby.
|
4
|
+
#
|
5
|
+
# Copyright 2005 Austin Ziegler
|
6
|
+
# http://rubyforge.org/ruby-pdf/
|
7
|
+
#
|
8
|
+
# Licensed under a MIT-style licence.
|
9
|
+
#
|
10
|
+
# $Id$
|
11
|
+
#++
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../lib") if __FILE__ == $0
|
14
|
+
require 'test/unit' unless defined? $ZENTEST and $ZENTEST
|
15
|
+
require 'color'
|
16
|
+
|
17
|
+
module TestColor
|
18
|
+
class TestYIQ < Test::Unit::TestCase
|
19
|
+
def setup
|
20
|
+
@yiq = Color::YIQ.from_fraction(0.1, 0.2, 0.3)
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_brightness
|
24
|
+
assert_in_delta(0.1, @yiq.brightness, 1e-4)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_i
|
28
|
+
assert_in_delta(0.2, @yiq.i, 1e-4)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_i_equals
|
32
|
+
assert_in_delta(0.2, @yiq.i, 1e-4)
|
33
|
+
assert_nothing_raised { @yiq.i = 0.5 }
|
34
|
+
assert_in_delta(0.5, @yiq.i, 1e-4)
|
35
|
+
assert_nothing_raised { @yiq.i = 5 }
|
36
|
+
assert_in_delta(1.0, @yiq.i, 1e-4)
|
37
|
+
assert_nothing_raised { @yiq.i = -5 }
|
38
|
+
assert_in_delta(0.0, @yiq.i, 1e-4)
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_q
|
42
|
+
assert_in_delta(0.3, @yiq.q, 1e-4)
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_q_equals
|
46
|
+
assert_in_delta(0.3, @yiq.q, 1e-4)
|
47
|
+
assert_nothing_raised { @yiq.q = 0.5 }
|
48
|
+
assert_in_delta(0.5, @yiq.q, 1e-4)
|
49
|
+
assert_nothing_raised { @yiq.q = 5 }
|
50
|
+
assert_in_delta(1.0, @yiq.q, 1e-4)
|
51
|
+
assert_nothing_raised { @yiq.q = -5 }
|
52
|
+
assert_in_delta(0.0, @yiq.q, 1e-4)
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_to_grayscale
|
56
|
+
assert_kind_of(Color::GrayScale, @yiq.to_grayscale)
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_to_greyscale
|
60
|
+
assert_kind_of(Color::GreyScale, @yiq.to_greyscale)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_to_yiq
|
64
|
+
assert_equal(@yiq, @yiq.to_yiq)
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_y
|
68
|
+
assert_in_delta(0.1, @yiq.y, 1e-4)
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_y_equals
|
72
|
+
assert_in_delta(0.1, @yiq.y, 1e-4)
|
73
|
+
assert_nothing_raised { @yiq.y = 0.5 }
|
74
|
+
assert_in_delta(0.5, @yiq.y, 1e-4)
|
75
|
+
assert_nothing_raised { @yiq.y = 5 }
|
76
|
+
assert_in_delta(1.0, @yiq.y, 1e-4)
|
77
|
+
assert_nothing_raised { @yiq.y = -5 }
|
78
|
+
assert_in_delta(0.0, @yiq.y, 1e-4)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
data/tests/testall.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#--
|
3
|
+
# Colour management with Ruby.
|
4
|
+
#
|
5
|
+
# Copyright 2005 Austin Ziegler
|
6
|
+
# http://rubyforge.org/ruby-pdf/
|
7
|
+
#
|
8
|
+
# Licensed under a MIT-style licence.
|
9
|
+
#
|
10
|
+
# $Id$
|
11
|
+
#++
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../lib") if __FILE__ == $0
|
14
|
+
|
15
|
+
puts "Checking for test cases:"
|
16
|
+
Dir['test_*.rb'].each do |testcase|
|
17
|
+
puts "\t#{testcase}"
|
18
|
+
require testcase
|
19
|
+
end
|
20
|
+
puts " "
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ripta-color-tools
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.4.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Austin Ziegler
|
8
|
+
autorequire: color
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-09 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: color-tools is a Ruby library to provide RGB, CMYK, and other colourspace
|
14
|
+
support to applications that require it. It also provides 152 named RGB colours.
|
15
|
+
It offers 152 named RGB colours (184 with spelling variations) that are commonly
|
16
|
+
supported and used in HTML, SVG, and X11 applications. A technique for generating
|
17
|
+
a monochromatic contrasting palette is also included.
|
18
|
+
email: austin@rubyforge.org
|
19
|
+
executables: []
|
20
|
+
extensions: []
|
21
|
+
extra_rdoc_files:
|
22
|
+
- README.rdoc
|
23
|
+
- Install
|
24
|
+
- Changelog
|
25
|
+
files:
|
26
|
+
- Changelog
|
27
|
+
- Install
|
28
|
+
- README.rdoc
|
29
|
+
- Rakefile
|
30
|
+
- lib/color.rb
|
31
|
+
- lib/color/cmyk.rb
|
32
|
+
- lib/color/css.rb
|
33
|
+
- lib/color/grayscale.rb
|
34
|
+
- lib/color/hsl.rb
|
35
|
+
- lib/color/palette.rb
|
36
|
+
- lib/color/palette/gimp.rb
|
37
|
+
- lib/color/palette/monocontrast.rb
|
38
|
+
- lib/color/rgb-colors.rb
|
39
|
+
- lib/color/rgb.rb
|
40
|
+
- lib/color/rgb/metallic.rb
|
41
|
+
- lib/color/yiq.rb
|
42
|
+
- metaconfig
|
43
|
+
- pre-setup.rb
|
44
|
+
- setup.rb
|
45
|
+
- tests/test_cmyk.rb
|
46
|
+
- tests/test_css.rb
|
47
|
+
- tests/test_gimp.rb
|
48
|
+
- tests/test_grayscale.rb
|
49
|
+
- tests/test_hsl.rb
|
50
|
+
- tests/test_monocontrast.rb
|
51
|
+
- tests/test_rgb.rb
|
52
|
+
- tests/test_yiq.rb
|
53
|
+
- tests/testall.rb
|
54
|
+
homepage: http://rubyforge.org/projects/ruby-pdf
|
55
|
+
licenses: []
|
56
|
+
metadata: {}
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options:
|
59
|
+
- "--title"
|
60
|
+
- ripta-color-tools
|
61
|
+
- "--main"
|
62
|
+
- README.rdoc
|
63
|
+
- "--line-numbers"
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project: ruby-pdf
|
78
|
+
rubygems_version: 2.2.2
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
81
|
+
summary: color-tools provides colour space definition and manpiulation as well as
|
82
|
+
commonly named RGB colours.
|
83
|
+
test_files: []
|
84
|
+
has_rdoc: true
|