color_code 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/color_code/hsl.rb +6 -6
- data/lib/color_code/rgb.rb +4 -3
- data/lib/color_code/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17cfaf9e8e642cfb2707f22f973e5f0a70777edc
|
4
|
+
data.tar.gz: 417e3430223b112ddfe3d29babc1286c2910ec68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4433dba7a060610b6237c62cf0b89bba444edc900eff01b78441693e2eaf0e38713fd09bedd6ff7e95fd3f85509d0441d14f977a361ce641cf079b0e5462fb2b
|
7
|
+
data.tar.gz: eafcda60d18708e40f883f2e0f070e58edf49790a71e53c8ddfde855fe526ede868ced1051257aeafc588519b820d8ca210cd19f38591a91be016c290ed5c05e
|
data/README.md
CHANGED
@@ -56,7 +56,7 @@ rgb.to_s # => '#ff0000'
|
|
56
56
|
|
57
57
|
## Contributing
|
58
58
|
|
59
|
-
1. Fork it ( https://github.com/
|
59
|
+
1. Fork it ( https://github.com/shiro16/color_code/fork )
|
60
60
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
61
61
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
62
62
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/color_code/hsl.rb
CHANGED
@@ -47,28 +47,28 @@ module ColorCode
|
|
47
47
|
case @h
|
48
48
|
when 0...60
|
49
49
|
r = max
|
50
|
-
g = (@h
|
50
|
+
g = (@h.quo(60).to_f) * (max - min) + min
|
51
51
|
b = min
|
52
52
|
when 60...120
|
53
|
-
r = ((120 - @h)
|
53
|
+
r = ((120 - @h).quo(60).to_f) * (max - min) + min
|
54
54
|
g = max
|
55
55
|
b = min
|
56
56
|
when 120...180
|
57
57
|
r = min
|
58
58
|
g = max
|
59
|
-
b = ((@h - 120)
|
59
|
+
b = ((@h - 120).quo(60).to_f) * (max - min) + min
|
60
60
|
when 180...240
|
61
61
|
r = min
|
62
|
-
g = ((240 - @h)
|
62
|
+
g = ((240 - @h).quo(60).to_f) * (max - min) + min
|
63
63
|
b = max
|
64
64
|
when 240...300
|
65
|
-
r = ((@h - 240)
|
65
|
+
r = ((@h - 240).quo(60).to_f) * (max - min) + min
|
66
66
|
g = min
|
67
67
|
b = max
|
68
68
|
when 300..360
|
69
69
|
r = max
|
70
70
|
g = min
|
71
|
-
b = ((360 - @h)
|
71
|
+
b = ((360 - @h).quo(60).to_f) * (max - min) + min
|
72
72
|
end
|
73
73
|
[r.round, g.round, b.round]
|
74
74
|
end
|
data/lib/color_code/rgb.rb
CHANGED
@@ -37,17 +37,18 @@ module ColorCode
|
|
37
37
|
return 0 if @r == @g && @g == @b
|
38
38
|
hue = case max
|
39
39
|
when @r
|
40
|
-
60 * ((@g - @b)
|
40
|
+
60 * ((@g - @b).quo(max - min).to_f)
|
41
41
|
when @g
|
42
|
-
60 * ((@b - @r)
|
42
|
+
60 * ((@b - @r).quo(max - min).to_f) + 120
|
43
43
|
when @b
|
44
|
-
60 * ((@r - @g)
|
44
|
+
60 * ((@r - @g).quo(max - min).to_f) + 240
|
45
45
|
end
|
46
46
|
hue += 360 if hue < 0
|
47
47
|
hue.round
|
48
48
|
end
|
49
49
|
|
50
50
|
def s
|
51
|
+
return 0 if max == min
|
51
52
|
converge = (max + min) / 2
|
52
53
|
|
53
54
|
saturation = if converge < 128
|
data/lib/color_code/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: color_code
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- shiro16
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|