color_lib 1.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.travis.yml +7 -0
- data/CHANGELOG +96 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +21 -0
- data/README.md +25 -0
- data/Rakefile +11 -0
- data/color_lib.gemspec +24 -0
- data/lib/color_lib.rb +139 -0
- data/lib/color_lib/cmyk.rb +280 -0
- data/lib/color_lib/css.rb +15 -0
- data/lib/color_lib/grayscale.rb +205 -0
- data/lib/color_lib/hsl.rb +221 -0
- data/lib/color_lib/palette.rb +4 -0
- data/lib/color_lib/palette/adobecolor.rb +265 -0
- data/lib/color_lib/palette/gimp.rb +103 -0
- data/lib/color_lib/palette/monocontrast.rb +169 -0
- data/lib/color_lib/pantone.rb +1499 -0
- data/lib/color_lib/rgb-colors.rb +343 -0
- data/lib/color_lib/rgb.rb +461 -0
- data/lib/color_lib/rgb/metallic.rb +31 -0
- data/lib/color_lib/version.rb +3 -0
- data/lib/color_lib/yiq.rb +79 -0
- data/lib/test/unit/assertions.rb +332 -0
- data/setup.rb +1588 -0
- data/test/test_adobecolor.rb +404 -0
- data/test/test_cmyk.rb +117 -0
- data/test/test_color.rb +129 -0
- data/test/test_css.rb +18 -0
- data/test/test_gimp.rb +87 -0
- data/test/test_grayscale.rb +110 -0
- data/test/test_hsl.rb +140 -0
- data/test/test_monocontrast.rb +131 -0
- data/test/test_rgb.rb +333 -0
- data/test/test_yiq.rb +62 -0
- metadata +132 -0
data/test/test_yiq.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'test/unit/assertions'
|
3
|
+
require 'color_lib'
|
4
|
+
|
5
|
+
module TestColorLib
|
6
|
+
class TestYIQ < Minitest::Test
|
7
|
+
include Test::Unit::Assertions
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@yiq = ColorLib::YIQ.from_fraction(0.1, 0.2, 0.3)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_brightness
|
14
|
+
assert_in_delta(0.1, @yiq.brightness, ColorLib::COLOR_TOLERANCE)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_i
|
18
|
+
assert_in_delta(0.2, @yiq.i, ColorLib::COLOR_TOLERANCE)
|
19
|
+
assert_in_delta(0.2, @yiq.i, ColorLib::COLOR_TOLERANCE)
|
20
|
+
@yiq.i = 0.5
|
21
|
+
assert_in_delta(0.5, @yiq.i, ColorLib::COLOR_TOLERANCE)
|
22
|
+
@yiq.i = 5
|
23
|
+
assert_in_delta(1.0, @yiq.i, ColorLib::COLOR_TOLERANCE)
|
24
|
+
@yiq.i = -5
|
25
|
+
assert_in_delta(0.0, @yiq.i, ColorLib::COLOR_TOLERANCE)
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_q
|
29
|
+
assert_in_delta(0.3, @yiq.q, ColorLib::COLOR_TOLERANCE)
|
30
|
+
assert_in_delta(0.3, @yiq.q, ColorLib::COLOR_TOLERANCE)
|
31
|
+
@yiq.q = 0.5
|
32
|
+
assert_in_delta(0.5, @yiq.q, ColorLib::COLOR_TOLERANCE)
|
33
|
+
@yiq.q = 5
|
34
|
+
assert_in_delta(1.0, @yiq.q, ColorLib::COLOR_TOLERANCE)
|
35
|
+
@yiq.q = -5
|
36
|
+
assert_in_delta(0.0, @yiq.q, ColorLib::COLOR_TOLERANCE)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_to_grayscale
|
40
|
+
assert_equal(ColorLib::GrayScale.new(0.1), @yiq.to_grayscale)
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_to_yiq
|
44
|
+
assert_equal(@yiq, @yiq.to_yiq)
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_y
|
48
|
+
assert_in_delta(0.1, @yiq.y, ColorLib::COLOR_TOLERANCE)
|
49
|
+
assert_in_delta(0.1, @yiq.y, ColorLib::COLOR_TOLERANCE)
|
50
|
+
@yiq.y = 0.5
|
51
|
+
assert_in_delta(0.5, @yiq.y, ColorLib::COLOR_TOLERANCE)
|
52
|
+
@yiq.y = 5
|
53
|
+
assert_in_delta(1.0, @yiq.y, ColorLib::COLOR_TOLERANCE)
|
54
|
+
@yiq.y = -5
|
55
|
+
assert_in_delta(0.0, @yiq.y, ColorLib::COLOR_TOLERANCE)
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_inspect
|
59
|
+
assert_equal("YIQ [10.00%, 20.00%, 30.00%]", @yiq.inspect)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
metadata
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: color_lib
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.4.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brandfolder, Inc.
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.5'
|
55
|
+
description: A lib for working with colors in ruby
|
56
|
+
email:
|
57
|
+
- developers@brandfolder.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".travis.yml"
|
64
|
+
- CHANGELOG
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- color_lib.gemspec
|
70
|
+
- lib/color_lib.rb
|
71
|
+
- lib/color_lib/cmyk.rb
|
72
|
+
- lib/color_lib/css.rb
|
73
|
+
- lib/color_lib/grayscale.rb
|
74
|
+
- lib/color_lib/hsl.rb
|
75
|
+
- lib/color_lib/palette.rb
|
76
|
+
- lib/color_lib/palette/adobecolor.rb
|
77
|
+
- lib/color_lib/palette/gimp.rb
|
78
|
+
- lib/color_lib/palette/monocontrast.rb
|
79
|
+
- lib/color_lib/pantone.rb
|
80
|
+
- lib/color_lib/rgb-colors.rb
|
81
|
+
- lib/color_lib/rgb.rb
|
82
|
+
- lib/color_lib/rgb/metallic.rb
|
83
|
+
- lib/color_lib/version.rb
|
84
|
+
- lib/color_lib/yiq.rb
|
85
|
+
- lib/test/unit/assertions.rb
|
86
|
+
- setup.rb
|
87
|
+
- test/test_adobecolor.rb
|
88
|
+
- test/test_cmyk.rb
|
89
|
+
- test/test_color.rb
|
90
|
+
- test/test_css.rb
|
91
|
+
- test/test_gimp.rb
|
92
|
+
- test/test_grayscale.rb
|
93
|
+
- test/test_hsl.rb
|
94
|
+
- test/test_monocontrast.rb
|
95
|
+
- test/test_rgb.rb
|
96
|
+
- test/test_yiq.rb
|
97
|
+
homepage: https://github.com/brandfolder/color_lib
|
98
|
+
licenses:
|
99
|
+
- MIT
|
100
|
+
metadata: {}
|
101
|
+
post_install_message:
|
102
|
+
rdoc_options: []
|
103
|
+
require_paths:
|
104
|
+
- lib
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
requirements: []
|
116
|
+
rubyforge_project:
|
117
|
+
rubygems_version: 2.4.5
|
118
|
+
signing_key:
|
119
|
+
specification_version: 4
|
120
|
+
summary: A lib for colors
|
121
|
+
test_files:
|
122
|
+
- test/test_adobecolor.rb
|
123
|
+
- test/test_cmyk.rb
|
124
|
+
- test/test_color.rb
|
125
|
+
- test/test_css.rb
|
126
|
+
- test/test_gimp.rb
|
127
|
+
- test/test_grayscale.rb
|
128
|
+
- test/test_hsl.rb
|
129
|
+
- test/test_monocontrast.rb
|
130
|
+
- test/test_rgb.rb
|
131
|
+
- test/test_yiq.rb
|
132
|
+
has_rdoc:
|