husler 0.0.2 → 0.1.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.
- data/.gitignore +1 -0
- data/.travis.yml +11 -0
- data/Gemfile +5 -1
- data/README.md +6 -2
- data/Rakefile +5 -0
- data/husler.gemspec +2 -0
- data/lib/husler.rb +3 -4
- data/lib/husler/constants.rb +1 -0
- data/lib/husler/version.rb +1 -1
- data/spec/lib/husler_spec.rb +18 -0
- data/spec/spec_helper.rb +8 -0
- metadata +25 -4
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,10 +1,14 @@
|
|
1
|
-
# Husler
|
1
|
+
# Husler [](http://travis-ci.org/soulcutter/husler)
|
2
2
|
|
3
3
|
A ruby implementation of [HUSL, a human-friendly color space](http://boronine.com/husl/).
|
4
4
|
|
5
5
|
## Usage
|
6
6
|
|
7
|
-
|
7
|
+
```ruby
|
8
|
+
Husler.rgb_to_husl(r, g, b) # rgb values must be between 0 and 1
|
9
|
+
|
10
|
+
Husler.husl_to_rgb(h, s, l) # h(ue) is between 0-360 and s(aturation) and l(ightness) between 0-100
|
11
|
+
```
|
8
12
|
|
9
13
|
## Credit
|
10
14
|
|
data/Rakefile
CHANGED
data/husler.gemspec
CHANGED
data/lib/husler.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'mathn'
|
2
|
-
|
3
1
|
require "husler/version"
|
4
2
|
require 'husler/constants'
|
5
3
|
|
@@ -34,7 +32,7 @@ module Husler
|
|
34
32
|
sub1 = ((l + 16) ** 3) / 1560896.0
|
35
33
|
sub2 = sub1 > 0.008856 ? sub1 : (l / 903.3);
|
36
34
|
|
37
|
-
result =
|
35
|
+
result = INFINITY
|
38
36
|
|
39
37
|
M.each do |m1, m2, m3|
|
40
38
|
top = ((0.99915 * m1 + 1.05122 * m2 + 1.14460 * m3) * sub2);
|
@@ -89,8 +87,9 @@ module Husler
|
|
89
87
|
end
|
90
88
|
|
91
89
|
def xyz_rgb(tuple)
|
90
|
+
dup_tuple = tuple.dup
|
92
91
|
(0...3).each do |i|
|
93
|
-
tuple[i] = from_linear(dot_product(M[i],
|
92
|
+
tuple[i] = from_linear(dot_product(M[i], dup_tuple))
|
94
93
|
end
|
95
94
|
tuple
|
96
95
|
end
|
data/lib/husler/constants.rb
CHANGED
data/lib/husler/version.rb
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Husler do
|
4
|
+
context "#rgb_to_husl" do
|
5
|
+
it "matches the expected output from the canonical coffeescript implementation" do
|
6
|
+
# jQuery.husl.fromRGB(0.75, 0.5, 0.25);
|
7
|
+
Husler.rgb_to_husl(0.75, 0.5, 0.25).should == [41.92580295066964, 78.60025347503503, 58.774191389329374]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
context "#husl_to_rgb" do
|
12
|
+
it "matches the expected output from the canonical coffeescript implementation" do
|
13
|
+
# jQuery.husl.toRGB(41.92580295066964, 78.60025347503503, 58.774191389329374)
|
14
|
+
Husler.husl_to_rgb(41.92580295066964, 78.60025347503503, 58.774191389329374).should ==
|
15
|
+
[0.7499979858220194, 0.5000211204153698, 0.25000732006691057]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: husler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
13
|
-
dependencies:
|
12
|
+
date: 2012-10-14 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.11.0
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 2.11.0
|
14
30
|
description: A ruby implementation of HUSL, a human-friendly color space
|
15
31
|
email:
|
16
32
|
- bradley.schaefer@gmail.com
|
@@ -19,6 +35,7 @@ extensions: []
|
|
19
35
|
extra_rdoc_files: []
|
20
36
|
files:
|
21
37
|
- .gitignore
|
38
|
+
- .travis.yml
|
22
39
|
- Gemfile
|
23
40
|
- LICENSE.txt
|
24
41
|
- README.md
|
@@ -27,6 +44,8 @@ files:
|
|
27
44
|
- lib/husler.rb
|
28
45
|
- lib/husler/constants.rb
|
29
46
|
- lib/husler/version.rb
|
47
|
+
- spec/lib/husler_spec.rb
|
48
|
+
- spec/spec_helper.rb
|
30
49
|
homepage: ''
|
31
50
|
licenses: []
|
32
51
|
post_install_message:
|
@@ -51,4 +70,6 @@ rubygems_version: 1.8.24
|
|
51
70
|
signing_key:
|
52
71
|
specification_version: 3
|
53
72
|
summary: A ruby implementation of HUSL, a human-friendly color space
|
54
|
-
test_files:
|
73
|
+
test_files:
|
74
|
+
- spec/lib/husler_spec.rb
|
75
|
+
- spec/spec_helper.rb
|