color-proximity 0.1.0 → 0.2.0

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: 488d3bfd9f4b8ebadea3e5d8bc25436ded1df9a3
4
- data.tar.gz: 64026bab9444f1ec94d354e752e0763660b75030
3
+ metadata.gz: 26f66c6cc2bf0d6b54e23835bfd0641a6defdc89
4
+ data.tar.gz: 3f1f9533450447ee0ac35b51fc06f49d68229fd1
5
5
  SHA512:
6
- metadata.gz: 2b9ff497a438edd22b1e6fa0164bc3b62c88dd77b299d79be423873c96f655cc75b14206b5029bac605d27793a06b82a29c632456d821fd64f168ab1c3e587d3
7
- data.tar.gz: ff97ac4face64b0b324768359a51618acbf544ffc4727b5e858e04f22be204de18dc635899765e9b6c920dec8a784407cf346cdc2ec486f8489c0f18ea598d54
6
+ metadata.gz: d715b66926a465a0c49b719d49d6d1df7b6082fbe7236183726515dfec04d1db3adf77ed99d9a6821d1f6f050480bdf37ddc8fd77e114268803ab162372da237
7
+ data.tar.gz: 0731b9f9bf36ca012dcde04f0a6a51b2e9ce259d0cfcaf52946d4a5531fb229249a4bf490f9b46b4ec1d73a8711a0d2b38ccb4f602003c1aa72f4a9e34bd7746
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  Given a threshold and a collection of colors, you'll be able to determine how close a given color is to matching a list.
6
6
 
7
- A [Euclidean distance algorithm](http://www.compuphase.com/cmetric.htm) is used to determine matches.
7
+ [A gem](https://github.com/mmozuras/color_difference) that implements a [CIEDE2000 color-difference formula](http://www.ece.rochester.edu/~gsharma/ciede2000/ciede2000noteCRNA.pdf) is the main backend used.
8
8
 
9
9
  ## Usage
10
10
 
@@ -18,6 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
19
  spec.require_paths = ["lib"]
20
20
 
21
+ spec.add_dependency 'color_difference', '~> 0.0.1'
21
22
  spec.add_development_dependency 'rspec', '~> 3.1'
22
- spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency 'rake', '~> 10.0'
23
24
  end
@@ -1,4 +1,5 @@
1
- require "color-proximity/version"
1
+ require 'color-proximity/version'
2
+ require 'color_difference'
2
3
 
3
4
  class ColorProximity
4
5
 
@@ -26,15 +27,7 @@ class ColorProximity
26
27
  private
27
28
 
28
29
  def proximity_of(color, another_color)
29
- color_red, color_green, color_blue = split_color(color)
30
- another_color_red, another_color_green, another_color_blue = split_color(another_color)
31
-
32
- color_red_mean = (color_red + another_color_red) / 2
33
- color_red_gap = color_red - another_color_red
34
- color_green_gap = color_green - another_color_green
35
- color_blue_gap = color_blue - another_color_blue
36
-
37
- euclidean_distance(color_red_mean, color_red_gap, color_green_gap, color_blue_gap)
30
+ ColorDifference.cie2000(split_color(color), split_color(another_color)).round(5)
38
31
  end
39
32
 
40
33
  def split_color(color)
@@ -42,14 +35,6 @@ class ColorProximity
42
35
  green = (color[2] + color[3]).to_i(16)
43
36
  blue = (color[4] + color[5]).to_i(16)
44
37
 
45
- [red, green, blue]
46
- end
47
-
48
- def euclidean_distance(red_mean, red_gap, green_gap, blue_gap)
49
- red_weight = ((512 + red_mean) * red_gap**2) >> 8
50
- green_weight = 4 * green_gap**2
51
- blue_weight = ((767 - red_mean) * blue_gap**2) >> 8
52
-
53
- Math.sqrt(red_weight + green_weight + blue_weight)
38
+ { r: red, g: green, b: blue }
54
39
  end
55
40
  end
@@ -1,3 +1,3 @@
1
1
  class ColorProximity
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: color-proximity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen Torikian
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-04-01 00:00:00.000000000 Z
11
+ date: 2015-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: color_difference
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.0.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.0.1
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rspec
15
29
  requirement: !ruby/object:Gem::Requirement