colourdistance 0.8.9 → 0.9.11

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: 0f8d3f1b085acd7231e589d416f91ead838ee3b1
4
- data.tar.gz: 01a30d2fb064dd05a1e5ede282f6f1238bcb4465
3
+ metadata.gz: 93f98c9462411cf0f285710f220832a91a7fe543
4
+ data.tar.gz: 09995502796c051e61f29d328bedfade685d1cb5
5
5
  SHA512:
6
- metadata.gz: 862daa1ff70ddfb086a34a0c7bb6efb1b37e2edcbc49ed3f1868c3d0ddd4a0d44e6a47e882d5cb065000912c355277102456f86a1aac62ef75c5f9b4dfcbe71e
7
- data.tar.gz: 88a2878eea7da0185351b0e97f143434495bf97986bcaa15da9df0fddb5f1301a1375c63e3899eda14048009fd22aeabffddfef1f364e5a202a0319c13e56fd5
6
+ metadata.gz: 83a632c000502980fb249747d8f0b035f929936f9190a0c36502d8852b9b7649cebb85e1af2785a8a4df7d31dccee6bfca5d2217cdadb07987fbd0667cf6ef33
7
+ data.tar.gz: 89ed50be64c3cee7eac78b9b87948ef363e67e665e2d7f282782ab4b98223987ddea8ef22b70afa4e1b5bac8d0d4d43c245d7b0b2ad5816a496b76e009e9aa90
data/.travis.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1.6
4
- before_install: gem install bundler -v 1.10.5
3
+ - 2.0.0
4
+ before_install: gem install bundler -v 1.10.3
data/Rakefile CHANGED
@@ -1,5 +1,4 @@
1
1
  require "bundler/gem_tasks"
2
- require "inline"
3
2
  require 'rspec/core/rake_task'
4
3
 
5
4
  RSpec::Core::RakeTask.new(:spec)
@@ -2,6 +2,7 @@
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'colourdistance/version'
5
+ require 'rake/extensiontask'
5
6
 
6
7
  Gem::Specification.new do |spec|
7
8
  spec.name = "colourdistance"
@@ -10,7 +11,7 @@ Gem::Specification.new do |spec|
10
11
  spec.email = ["theseventhorange@gmail.com"]
11
12
 
12
13
  spec.summary = "Measures the difference (as a distance between colors in lab space) between colours. Takes rgb input. Will add support for xyz and lab around version 1.0."
13
- spec.description = "Currently only contains two options, ciede94 and ciede2000, both weighted to (roughly) a [0,1] scale (actually possible to get very slightly above 1). Will add more. Both are my own implementations, and ciede94 is probably wrong because of it."
14
+ spec.description = "Currently only contains two options, ciede94 and ciede2000, both weighted to (roughly) a [0,1] scale (actually possible to get very slightly above 1). Will add more. Both are my own implementations, and ciede94 is probably wrong because of it. Thanks go out to Josh Clayton (https://robots.thoughtbot.com/get-your-c-on), for helping me to understand the structure I was attempting to acheive."
14
15
  spec.license = "MIT"
15
16
 
16
17
  # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
@@ -25,11 +26,14 @@ Gem::Specification.new do |spec|
25
26
  spec.bindir = "exe"
26
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
28
  spec.require_paths = ["lib"]
29
+ spec.extensions = ["ext/colourdistance/extconf.rb"]
28
30
 
29
31
  spec.add_development_dependency "bundler", "~> 1.10"
30
32
  spec.add_development_dependency "rake", "~> 10.0"
31
- spec.add_development_dependency "RubyInline", "~>3.12.4"
32
33
  spec.add_development_dependency "rspec"
34
+ spec.add_dependency "rake-compiler"
33
35
 
34
- spec.add_runtime_dependency "RubyInline", "~>3.12.4"
36
+ Rake::ExtensionTask.new("colourdistance") do |extension|
37
+ extension.lib_dir = "lib/colourdistance"
38
+ end
35
39
  end
@@ -0,0 +1,168 @@
1
+ #include <ruby.h>
2
+ #include <stdio.h>
3
+ #include <math.h>
4
+ #include "colourdistance.h"
5
+
6
+
7
+
8
+ void Init_colourdistance() {
9
+ VALUE rb_mColourdistance = rb_define_module("Colourdistance");
10
+ rb_define_singleton_method(rb_mColourdistance, "ciede2000", ciede2000, 2);
11
+ }
12
+
13
+ static VALUE ciede2000(const VALUE self, VALUE color1, VALUE color2) {
14
+ double pi = 3.1415927;
15
+ double e = 2.7182818;
16
+ double conversion = pi/180.0;
17
+ double l1;
18
+ double l2;
19
+ double a1;
20
+ double a2;
21
+
22
+ double r1 = NUM2DBL(rb_hash_aref(color1, rb_str_intern(rb_str_new2("r"))))/255.0;
23
+ double g1 = NUM2DBL(rb_hash_aref(color1, rb_str_intern(rb_str_new2("g"))))/255.0;
24
+ double b1 = NUM2DBL(rb_hash_aref(color1, rb_str_intern(rb_str_new2("b"))))/255.0;
25
+
26
+ double r2 = NUM2DBL(rb_hash_aref(color2, rb_str_intern(rb_str_new2("r"))))/255.0;
27
+ double g2 = NUM2DBL(rb_hash_aref(color2, rb_str_intern(rb_str_new2("g"))))/255.0;
28
+ double b2 = NUM2DBL(rb_hash_aref(color2, rb_str_intern(rb_str_new2("b"))))/255.0;
29
+
30
+ r1 = ((r1 <= 0.04045) ? r1 / 12.92 : pow(((r1 + 0.055) / 1.055),2.4));
31
+ g1 = ((g1 <= 0.04045) ? g1 / 12.92 : pow(((g1 + 0.055) / 1.055),2.4));
32
+ b1 = ((b1 <= 0.04045) ? b1 / 12.92 : pow(((b1 + 0.055) / 1.055),2.4));
33
+
34
+ r2 = ((r2 <= 0.04045) ? r2 / 12.92 : pow(((r2 + 0.055) / 1.055),2.4));
35
+ g2 = ((g2 <= 0.04045) ? g2 / 12.92 : pow(((g2 + 0.055) / 1.055),2.4));
36
+ b2 = ((b2 <= 0.04045) ? b2 / 12.92 : pow(((b2 + 0.055) / 1.055),2.4));
37
+
38
+ double x1 = 0.412453 * r1 + 0.357580 * g1 + 0.180423 * b1;
39
+ double y1 = 0.212671 * r1 + 0.715160 * g1 + 0.072169 * b1;
40
+ double z1 = 0.019334 * r1 + 0.119193 * g1 + 0.950227 * b1;
41
+
42
+ double x2 = 0.412453 * r2 + 0.357580 * g2 + 0.180423 * b2;
43
+ double y2 = 0.212671 * r2 + 0.715160 * g2 + 0.072169 * b2;
44
+ double z2 = 0.019334 * r2 + 0.119193 * g2 + 0.950227 * b2;
45
+
46
+ double fx;
47
+ double fy;
48
+ double fz;
49
+
50
+ if(x1 <= 0.008856){
51
+ fx = 7.787 * x1/0.95047 + 16.0/116.0;
52
+ }else{
53
+ fx = cbrt(x1/0.95047);
54
+ }
55
+
56
+ if(y1 <= 0.008856){
57
+ l1 = 903.3 * y1;
58
+ fy = (7.787 * y1 + 16.0/116.0);
59
+ }else{
60
+ l1 = 116.0 * cbrt(y1) - 16.0;
61
+ fy = cbrt(y1);
62
+ }
63
+
64
+ if(z1 <= 0.008856){
65
+ fz = 7.787 * z1/1.08883 + 16.0/116.0;
66
+ }else{
67
+ fz = cbrt(z1/1.08883);
68
+ }
69
+
70
+ a1 = 500.0 * (fx-fy);
71
+ b1 = 200.0 * (fy-fz);
72
+
73
+ if(x2 <= 0.008856){
74
+ fx = (7.787 * x2/0.95047 + 16.0/116.0);
75
+ }else{
76
+ fx = cbrt(x2/0.95047);
77
+ }
78
+
79
+ if(y2 <= 0.008856){
80
+ l2 = 903.3 * y2;
81
+ fy = (7.787 * y2 + 16.0/116.0);
82
+ }else{
83
+ l2 = 116.0 * cbrt(y2) - 16.0;
84
+ fy = cbrt(y2);
85
+ }
86
+
87
+ if(z2 <= 0.008856){
88
+ fz = (7.787 * z2/1.08883 + 16.0/116.0);
89
+ }else{
90
+ fz = cbrt(z2/1.08883);
91
+ }
92
+
93
+ a2 = 500.0 * (fx-fy);
94
+ b2 = 200.0 * (fy-fz);
95
+
96
+ double c1 = sqrt(a1*a1+b1*b1);
97
+ double c2 = sqrt(a2*a2+b2*b2);
98
+ double cdelta = c2 - c1;
99
+
100
+ double lbar = (l1 + l2)/2.0;
101
+ double cbar = (c1 + c2)/2.0;
102
+
103
+ double lbaradj = (lbar - 50.0)*(lbar - 50.0);
104
+ double cbaradj = sqrt(pow(cbar,7)/(pow(cbar,7)+6103515625.0));
105
+
106
+ double a1prime = a1 + (a1/2.0) * (1.0-cbaradj);
107
+ double a2prime = a2 + (a2/2.0) * (1.0-cbaradj);
108
+
109
+ double c1prime = sqrt(a1prime*a1prime+b1*b1);
110
+ double c2prime = sqrt(a2prime*a2prime+b2*b2);
111
+ double cprime = (c1prime + c2prime)/2.0;
112
+ double cprimeadj = sqrt(pow(cprime,7)/(pow(cprime,7)+6103515625.0));
113
+ double cprimedelta = c2prime - c1prime;
114
+
115
+ double h1;
116
+ double h2;
117
+ if(c1 == 0.0){
118
+ h1 = 0.0;
119
+ }else{
120
+ h1 = fmod(atan2(b1,a1prime)*180.0/pi,360.0);
121
+ }
122
+ if(c2 == 0.0){
123
+ h2 = 0.0;
124
+ }else{
125
+ h2 = fmod(atan2(b2,a2prime)*180.0/pi,360.0);
126
+ }
127
+
128
+ double h;
129
+ if (fabs(h2 - h1) <= 180.0){
130
+ h = h2 - h1;
131
+ }else if(h2 <= h1){
132
+ h = h2 - h1 + 360.0;
133
+ }else{
134
+ h = h2 - h1 - 360.0;
135
+ }
136
+
137
+ double hdelta = 2.0 * sqrt(c1prime * c2prime) * sin(conversion*h/2.0);
138
+ double hprime = (h1 + h2)/2.0;
139
+ if (fabs(h1 - h2) > 180.0){
140
+ hprime += 180.0;
141
+ }
142
+ if(c1prime == 0.0 || c2prime == 0.0){
143
+ hprime *= 2.0;
144
+ }
145
+
146
+ double t = 1.0 - 0.17*cos(conversion*(hprime-30.0)) +
147
+ 0.24*cos(conversion*(2.0*hprime)) +
148
+ 0.32*cos(conversion*(3.0*hprime + 6.0)) -
149
+ 0.20*cos(conversion*(4.0*hprime-63.0));
150
+
151
+ double sl = 1.0 + 0.015 * lbaradj/sqrt(20+lbaradj);
152
+ double sc = 1.0 + 0.045*cprime;
153
+ double sh = 1.0 + 0.015*cprime*t;
154
+
155
+ if (hprime < 0.0){
156
+ hprime += 360.0;
157
+ }
158
+
159
+ double rt = -2.0*cprimeadj*sin(conversion*60.0*pow(e,(hprime-275.0)*(hprime-275.0)/(-625.0)));
160
+
161
+ double ldiff = (l1 - l2)/sl;
162
+ double adiff = cprimedelta/sc;
163
+ double bdiff = hdelta/sh;
164
+ double rdiff = rt*adiff*bdiff;
165
+ double val = sqrt(ldiff*ldiff+adiff*adiff+bdiff*bdiff+rdiff)/100.0;
166
+
167
+ return DBL2NUM(val);
168
+ }
@@ -0,0 +1,6 @@
1
+ #ifndef __colourdistance_h__
2
+ #define __colourdistance_h__
3
+
4
+ static VALUE ciede2000(VALUE,VALUE,VALUE);
5
+
6
+ #endif
@@ -0,0 +1,9 @@
1
+ require 'mkmf'
2
+ require 'rake/extensiontask'
3
+
4
+ $CFLAGS = "--std=c99 -O"
5
+
6
+ extension_name = 'colourdistance/colourdistance'
7
+
8
+ create_makefile(extension_name)
9
+ Rake::ExtensionTask.new(extension_name)
@@ -1,273 +1,5 @@
1
- require "colourdistance/version"
2
- require "inline"
3
-
4
- module Colourdistance
5
- inline(:C) do |builder|
6
- builder.include '<stdio.h>'
7
- builder.include '<math.h>'
8
-
9
- builder.c_singleton 'VALUE ciede94(VALUE color1, VALUE color2) {
10
- double pi = 3.1415927;
11
- double e = 2.7182818;
12
- double l1;
13
- double l2;
14
- double a1;
15
- double a2;
16
-
17
-
18
- double r1 = NUM2DBL(rb_hash_aref(color1, rb_str_intern(rb_str_new2("r"))))/255.0;
19
- double g1 = NUM2DBL(rb_hash_aref(color1, rb_str_intern(rb_str_new2("g"))))/255.0;
20
- double b1 = NUM2DBL(rb_hash_aref(color1, rb_str_intern(rb_str_new2("b"))))/255.0;
21
-
22
- double r2 = NUM2DBL(rb_hash_aref(color2, rb_str_intern(rb_str_new2("r"))))/255.0;
23
- double g2 = NUM2DBL(rb_hash_aref(color2, rb_str_intern(rb_str_new2("g"))))/255.0;
24
- double b2 = NUM2DBL(rb_hash_aref(color2, rb_str_intern(rb_str_new2("b"))))/255.0;
25
-
26
- r1 = ((r1 <= 0.04045) ? r1 / 12.92 : pow(((r1 + 0.055) / 1.055),2.4));
27
- g1 = ((g1 <= 0.04045) ? g1 / 12.92 : pow(((g1 + 0.055) / 1.055),2.4));
28
- b1 = ((b1 <= 0.04045) ? b1 / 12.92 : pow(((b1 + 0.055) / 1.055),2.4));
29
-
30
- r2 = ((r2 <= 0.04045) ? r2 / 12.92 : pow(((r2 + 0.055) / 1.055),2.4));
31
- g2 = ((g2 <= 0.04045) ? g2 / 12.92 : pow(((g2 + 0.055) / 1.055),2.4));
32
- b2 = ((b2 <= 0.04045) ? b2 / 12.92 : pow(((b2 + 0.055) / 1.055),2.4));
33
-
34
- double x1 = 0.412453 * r1 + 0.357580 * g1 + 0.180423 * b1;
35
- double y1 = 0.212671 * r1 + 0.715160 * g1 + 0.072169 * b1;
36
- double z1 = 0.019334 * r1 + 0.119193 * g1 + 0.950227 * b1;
37
-
38
- double x2 = 0.412453 * r2 + 0.357580 * g2 + 0.180423 * b2;
39
- double y2 = 0.212671 * r2 + 0.715160 * g2 + 0.072169 * b2;
40
- double z2 = 0.019334 * r2 + 0.119193 * g2 + 0.950227 * b2;
41
-
42
- double fx;
43
- double fy;
44
- double fz;
45
-
46
- if(x1 <= 0.008856){
47
- fx = 7.787 * x1/0.95047 + 16.0/116.0;
48
- }else{
49
- fx = cbrt(x1/0.95047);
50
- }
51
-
52
- if(y1 <= 0.008856){
53
- l1 = 903.3 * y1;
54
- fy = (7.787 * y1 + 16.0/116.0);
55
- }else{
56
- l1 = 116.0 * cbrt(y1) - 16.0;
57
- fy = cbrt(y1);
58
- }
59
-
60
- if(z1 <= 0.008856){
61
- fz = 7.787 * z1/1.08883 + 16.0/116.0;
62
- }else{
63
- fz = cbrt(z1/1.08883);
64
- }
65
-
66
- a1 = 500.0 * (fx-fy);
67
- b1 = 200.0 * (fy-fz);
68
-
69
-
70
- if(x2 <= 0.008856){
71
- fx = (7.787 * x2/0.95047 + 16.0/116.0);
72
- }else{
73
- fx = cbrt(x2/0.95047);
74
- }
75
-
76
- if(y2 <= 0.008856){
77
- l2 = 903.3 * y2;
78
- fy = (7.787 * y2 + 16.0/116.0);
79
- }else{
80
- l2 = 116.0 * cbrt(y2) - 16.0;
81
- fy = cbrt(y2);
82
- }
83
-
84
- if(z2 <= 0.008856){
85
- fz = (7.787 * z2/1.08883 + 16.0/116.0);
86
- }else{
87
- fz = cbrt(z2/1.08883);
88
- }
89
-
90
- a2 = 500.0 * (fx-fy);
91
- b2 = 200.0 * (fy-fz);
92
-
93
- double kl = 2.0;
94
- double k1 = 0.048;
95
- double k2 = 0.014;
96
-
97
- double c1 = sqrt(a1*a1+b1*b1);
98
- double c2 = sqrt(a2*a2+b2*b2);
99
- double cdelta = c2 - c1;
100
-
101
- double sc = 1.0 + k1 * c1;
102
- double sh = 1.0 + k2 * c1;
103
-
104
- double habdelta = sqrt((a2-a1)*(a2-a1)+(b2-b1)*(b2-b1) - cdelta*cdelta);
105
-
106
- double ldiff = (l1 - l2)/kl;
107
- double adiff = cdelta/sc;
108
- double bdiff = habdelta/sh;
109
-
110
- return DBL2NUM(sqrt(ldiff*ldiff+adiff*adiff+bdiff*bdiff)/50.0);
111
- }'
112
-
113
- builder.c_singleton 'VALUE ciede2000(VALUE color1, VALUE color2) {
114
- double pi = 3.1415927;
115
- double e = 2.7182818;
116
- double conversion = pi/180;
117
- double _kL = 1.0;
118
- double _kC = 1.0;
119
- double _kH = 1.0;
120
- double l1;
121
- double l2;
122
- double a1;
123
- double a2;
124
-
125
- double r1 = NUM2DBL(rb_hash_aref(color1, rb_str_intern(rb_str_new2("r"))))/255.0;
126
- double g1 = NUM2DBL(rb_hash_aref(color1, rb_str_intern(rb_str_new2("g"))))/255.0;
127
- double b1 = NUM2DBL(rb_hash_aref(color1, rb_str_intern(rb_str_new2("b"))))/255.0;
128
-
129
- double r2 = NUM2DBL(rb_hash_aref(color2, rb_str_intern(rb_str_new2("r"))))/255.0;
130
- double g2 = NUM2DBL(rb_hash_aref(color2, rb_str_intern(rb_str_new2("g"))))/255.0;
131
- double b2 = NUM2DBL(rb_hash_aref(color2, rb_str_intern(rb_str_new2("b"))))/255.0;
132
-
133
- r1 = ((r1 <= 0.04045) ? r1 / 12.92 : pow(((r1 + 0.055) / 1.055),2.4));
134
- g1 = ((g1 <= 0.04045) ? g1 / 12.92 : pow(((g1 + 0.055) / 1.055),2.4));
135
- b1 = ((b1 <= 0.04045) ? b1 / 12.92 : pow(((b1 + 0.055) / 1.055),2.4));
136
-
137
- r2 = ((r2 <= 0.04045) ? r2 / 12.92 : pow(((r2 + 0.055) / 1.055),2.4));
138
- g2 = ((g2 <= 0.04045) ? g2 / 12.92 : pow(((g2 + 0.055) / 1.055),2.4));
139
- b2 = ((b2 <= 0.04045) ? b2 / 12.92 : pow(((b2 + 0.055) / 1.055),2.4));
140
-
141
- double x1 = 0.412453 * r1 + 0.357580 * g1 + 0.180423 * b1;
142
- double y1 = 0.212671 * r1 + 0.715160 * g1 + 0.072169 * b1;
143
- double z1 = 0.019334 * r1 + 0.119193 * g1 + 0.950227 * b1;
144
-
145
- double x2 = 0.412453 * r2 + 0.357580 * g2 + 0.180423 * b2;
146
- double y2 = 0.212671 * r2 + 0.715160 * g2 + 0.072169 * b2;
147
- double z2 = 0.019334 * r2 + 0.119193 * g2 + 0.950227 * b2;
148
-
149
- double fx;
150
- double fy;
151
- double fz;
152
-
153
- if(x1 <= 0.008856){
154
- fx = 7.787 * x1/0.95047 + 16.0/116.0;
155
- }else{
156
- fx = cbrt(x1/0.95047);
157
- }
158
-
159
- if(y1 <= 0.008856){
160
- l1 = 903.3 * y1;
161
- fy = (7.787 * y1 + 16.0/116.0);
162
- }else{
163
- l1 = 116.0 * cbrt(y1) - 16.0;
164
- fy = cbrt(y1);
165
- }
166
-
167
- if(z1 <= 0.008856){
168
- fz = 7.787 * z1/1.08883 + 16.0/116.0;
169
- }else{
170
- fz = cbrt(z1/1.08883);
171
- }
172
-
173
- a1 = 500.0 * (fx-fy);
174
- b1 = 200.0 * (fy-fz);
175
-
176
- if(x2 <= 0.008856){
177
- fx = (7.787 * x2/0.95047 + 16.0/116.0);
178
- }else{
179
- fx = cbrt(x2/0.95047);
180
- }
181
-
182
- if(y2 <= 0.008856){
183
- l2 = 903.3 * y2;
184
- fy = (7.787 * y2 + 16.0/116.0);
185
- }else{
186
- l2 = 116.0 * cbrt(y2) - 16.0;
187
- fy = cbrt(y2);
188
- }
189
-
190
- if(z2 <= 0.008856){
191
- fz = (7.787 * z2/1.08883 + 16.0/116.0);
192
- }else{
193
- fz = cbrt(z2/1.08883);
194
- }
195
-
196
- a2 = 500.0 * (fx-fy);
197
- b2 = 200.0 * (fy-fz);
198
-
199
- double c1 = sqrt(a1*a1+b1*b1);
200
- double c2 = sqrt(a2*a2+b2*b2);
201
- double cdelta = c2 - c1;
202
-
203
- double lbar = (l1 + l2)/2.0;
204
- double cbar = (c1 + c2)/2.0;
205
-
206
- double lbaradj = (lbar - 50.0)*(lbar - 50.0);
207
- double cbaradj = sqrt(pow(cbar,7)/(pow(cbar,7)+6103515625.0));
208
-
209
- double a1prime = a1 + (a1/2.0) * (1.0-cbaradj);
210
- double a2prime = a2 + (a2/2.0) * (1.0-cbaradj);
211
-
212
- double c1prime = sqrt(a1prime*a1prime+b1*b1);
213
- double c2prime = sqrt(a2prime*a2prime+b2*b2);
214
- double cprime = (c1prime + c2prime)/2.0;
215
- double cprimeadj = sqrt(pow(cprime,7)/(pow(cprime,7)+6103515625.0));
216
- double cprimedelta = c2prime - c1prime;
217
-
218
- double h1;
219
- double h2;
220
- if(c1 == 0.0){
221
- h1 = 0.0;
222
- }else{
223
- h1 = fmod(atan2(b1,a1prime)*180.0/pi,360.0);
224
- }
225
- if(c2 == 0.0){
226
- h2 = 0.0;
227
- }else{
228
- h2 = fmod(atan2(b2,a2prime)*180.0/pi,360.0);
229
- }
230
-
231
- double h;
232
- if (fabs(h2 - h1) <= 180.0){
233
- h = h2 - h1;
234
- }else if(h2 <= h1){
235
- h = h2 - h1 + 360.0;
236
- }else{
237
- h = h2 - h1 - 360.0;
238
- }
239
-
240
- double hdelta = 2.0 * sqrt(c1prime * c2prime) * sin(conversion*h/2.0);
241
- double hprime = (h1 + h2)/2.0;
242
- if (fabs(h1 - h2) > 180.0){
243
- hprime += 180.0;
244
- }
245
- if(c1prime == 0.0 || c2prime == 0.0){
246
- hprime *= 2.0;
247
- }
248
-
249
- double t = 1.0 - 0.17*cos(conversion*(hprime-30.0)) +
250
- 0.24*cos(conversion*(2.0*hprime)) +
251
- 0.32*cos(conversion*(3.0*hprime + 6.0)) -
252
- 0.20*cos(conversion*(4.0*hprime-63.0));
253
-
254
- double sl = 1.0 + 0.015 * lbaradj/sqrt(20+lbaradj);
255
- double sc = 1.0 + 0.045*cprime;
256
- double sh = 1.0 + 0.015*cprime*t;
257
-
258
- if (hprime < 0.0){
259
- hprime += 360.0;
260
- }
261
-
262
- double rt = -2.0*cprimeadj*sin(conversion*60.0*pow(e,(hprime-275.0)*(hprime-275.0)/(-625.0)));
263
-
264
- double ldiff = (l1 - l2)/sl;
265
- double adiff = cprimedelta/sc;
266
- double bdiff = hdelta/sh;
267
- double rdiff = rt*adiff*bdiff;
268
- double val = sqrt(ldiff*ldiff+adiff*adiff+bdiff*bdiff+rdiff)/100.0;
269
-
270
- return DBL2NUM(val);
271
- }'
272
- end
1
+ module Colordistance
2
+ autoload :Version, "colourdistance/version"
273
3
  end
4
+
5
+ require "colourdistance/colourdistance"
@@ -1,3 +1,3 @@
1
1
  module Colourdistance
2
- VERSION = "0.8.9"
2
+ VERSION = "0.9.11"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: colourdistance
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.9
4
+ version: 0.9.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Orange Seven
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-07-24 00:00:00.000000000 Z
11
+ date: 2015-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
- - !ruby/object:Gem::Dependency
42
- name: RubyInline
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ~>
46
- - !ruby/object:Gem::Version
47
- version: 3.12.4
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ~>
53
- - !ruby/object:Gem::Version
54
- version: 3.12.4
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: rspec
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -67,27 +53,29 @@ dependencies:
67
53
  - !ruby/object:Gem::Version
68
54
  version: '0'
69
55
  - !ruby/object:Gem::Dependency
70
- name: RubyInline
56
+ name: rake-compiler
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
- - - ~>
59
+ - - '>='
74
60
  - !ruby/object:Gem::Version
75
- version: 3.12.4
61
+ version: '0'
76
62
  type: :runtime
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
- - - ~>
66
+ - - '>='
81
67
  - !ruby/object:Gem::Version
82
- version: 3.12.4
68
+ version: '0'
83
69
  description: Currently only contains two options, ciede94 and ciede2000, both weighted
84
70
  to (roughly) a [0,1] scale (actually possible to get very slightly above 1). Will
85
71
  add more. Both are my own implementations, and ciede94 is probably wrong because
86
- of it.
72
+ of it. Thanks go out to Josh Clayton (https://robots.thoughtbot.com/get-your-c-on),
73
+ for helping me to understand the structure I was attempting to acheive.
87
74
  email:
88
75
  - theseventhorange@gmail.com
89
76
  executables: []
90
- extensions: []
77
+ extensions:
78
+ - ext/colourdistance/extconf.rb
91
79
  extra_rdoc_files: []
92
80
  files:
93
81
  - .gitignore
@@ -99,7 +87,11 @@ files:
99
87
  - bin/console
100
88
  - bin/setup
101
89
  - colourdistance.gemspec
90
+ - ext/colourdistance/colourdistance.c
91
+ - ext/colourdistance/colourdistance.h
92
+ - ext/colourdistance/extconf.rb
102
93
  - lib/colourdistance.rb
94
+ - lib/colourdistance/colourdistance.bundle
103
95
  - lib/colourdistance/version.rb
104
96
  homepage:
105
97
  licenses: