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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 04c12bb81259d3101eb3053fbc860ed4bc781dfd
4
- data.tar.gz: b463e4511965377b36077105a90eb3e9d924bb97
3
+ metadata.gz: 17cfaf9e8e642cfb2707f22f973e5f0a70777edc
4
+ data.tar.gz: 417e3430223b112ddfe3d29babc1286c2910ec68
5
5
  SHA512:
6
- metadata.gz: 6be20c301d73ff5f28348f9b98d14d817f3c79f24180aa50fb40939a92a720b54f2488405559529fbc3ab455af77f79c0420979e9e5b400ad322fb41d92e0849
7
- data.tar.gz: aa3bdd6d4a2837faa054d463b5d75fcfe42fa78d40641bb9c4e46001db12e0ebe882de488a942be70a83c54fb468bb5fbf05d784cb51154aaab14621a5db0cd5
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/[my-github-username]/color_code/fork )
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`)
@@ -47,28 +47,28 @@ module ColorCode
47
47
  case @h
48
48
  when 0...60
49
49
  r = max
50
- g = (@h / 60) * (max - min) + min
50
+ g = (@h.quo(60).to_f) * (max - min) + min
51
51
  b = min
52
52
  when 60...120
53
- r = ((120 - @h) / 60) * (max - min) + min
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) / 60) * (max - min) + min
59
+ b = ((@h - 120).quo(60).to_f) * (max - min) + min
60
60
  when 180...240
61
61
  r = min
62
- g = ((240 - @h) / 60) * (max - min) + min
62
+ g = ((240 - @h).quo(60).to_f) * (max - min) + min
63
63
  b = max
64
64
  when 240...300
65
- r = ((@h - 240) / 60) * (max - min) + min
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) / 60) * (max - min) + min
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
@@ -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) / (max - min))
40
+ 60 * ((@g - @b).quo(max - min).to_f)
41
41
  when @g
42
- 60 * ((@b - @r) / (max - min)) + 120
42
+ 60 * ((@b - @r).quo(max - min).to_f) + 120
43
43
  when @b
44
- 60 * ((@r - @g) / (max - min)) + 240
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
@@ -1,3 +1,3 @@
1
1
  module ColorCode
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
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.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-24 00:00:00.000000000 Z
11
+ date: 2015-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler