colourdistance 0.0.7
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.
- checksums.yaml +7 -0
- data/.DS_Store +0 -0
- data/.gitignore +9 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +8 -0
- data/README.md +41 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/colourdistance.gemspec +33 -0
- data/lib/.DS_Store +0 -0
- data/lib/colourdistance.rb +249 -0
- data/lib/colourdistance/version.rb +3 -0
- metadata +118 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: 2f540b8bfb96e37fbfe0d67c9e3947c7e963aa97
         | 
| 4 | 
            +
              data.tar.gz: 53afb6ae398ec5f078f4cd1daaac2ae002f41a3a
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: 07a6447f56413d8c43a154bee396ed247257e987e0852ee9e3df8958b2776d021b0022c26bc8419831e2aadf587db3ba0730f8caa7fee297ebefc77bb3e7fd0e
         | 
| 7 | 
            +
              data.tar.gz: 83cfb21d9961be9a6debc42a7f1f756a4074c229d854a481e3cb3bf1b2d194786057bd3c1de6f8ff5c3ee036d8cf169535936ff4d5fcf7472981cf1832307c9d
         | 
    
        data/.DS_Store
    ADDED
    
    | Binary file | 
    
        data/.gitignore
    ADDED
    
    
    
        data/.travis.yml
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/LICENSE.txt
    ADDED
    
    
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,41 @@ | |
| 1 | 
            +
            # Colourdistance
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/colourdistance`. To experiment with that code, run `bin/console` for an interactive prompt.
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            TODO: Delete this and the text above, and describe your gem
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            ## Installation
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            Add this line to your application's Gemfile:
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            ```ruby
         | 
| 12 | 
            +
            gem 'colourdistance'
         | 
| 13 | 
            +
            ```
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            And then execute:
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                $ bundle
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            Or install it yourself as:
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                $ gem install colourdistance
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            ## Usage
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            TODO: Write usage instructions here
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            ## Development
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
         | 
| 30 | 
            +
             | 
| 31 | 
            +
            To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            ## Contributing
         | 
| 34 | 
            +
             | 
| 35 | 
            +
            Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/colourdistance.
         | 
| 36 | 
            +
             | 
| 37 | 
            +
             | 
| 38 | 
            +
            ## License
         | 
| 39 | 
            +
             | 
| 40 | 
            +
            The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
         | 
| 41 | 
            +
             | 
    
        data/Rakefile
    ADDED
    
    
    
        data/bin/console
    ADDED
    
    | @@ -0,0 +1,14 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require "bundler/setup"
         | 
| 4 | 
            +
            require "colourdistance"
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            # You can add fixtures and/or initialization code here to make experimenting
         | 
| 7 | 
            +
            # with your gem easier. You can also use a different console, if you like.
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            # (If you use this, don't forget to add pry to your Gemfile!)
         | 
| 10 | 
            +
            # require "pry"
         | 
| 11 | 
            +
            # Pry.start
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            require "irb"
         | 
| 14 | 
            +
            IRB.start
         | 
    
        data/bin/setup
    ADDED
    
    
| @@ -0,0 +1,33 @@ | |
| 1 | 
            +
            # coding: utf-8
         | 
| 2 | 
            +
            lib = File.expand_path('../lib', __FILE__)
         | 
| 3 | 
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         | 
| 4 | 
            +
            require 'colourdistance/version'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Gem::Specification.new do |spec|
         | 
| 7 | 
            +
              spec.name          = "colourdistance"
         | 
| 8 | 
            +
              spec.version       = Colourdistance::VERSION
         | 
| 9 | 
            +
              spec.authors       = ["Orange Seven"]
         | 
| 10 | 
            +
              spec.email         = ["theseventhorange@gmail.com"]
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              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.license       = "MIT"
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
         | 
| 17 | 
            +
              # delete this section to allow pushing this gem to any host.
         | 
| 18 | 
            +
              if spec.respond_to?(:metadata)
         | 
| 19 | 
            +
                spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
         | 
| 20 | 
            +
              else
         | 
| 21 | 
            +
                raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
              spec.files         = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
         | 
| 25 | 
            +
              spec.bindir        = "exe"
         | 
| 26 | 
            +
              spec.executables   = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
         | 
| 27 | 
            +
              spec.require_paths = ["lib"]
         | 
| 28 | 
            +
             | 
| 29 | 
            +
              spec.add_development_dependency "bundler", "~> 1.10"
         | 
| 30 | 
            +
              spec.add_development_dependency "rake", "~> 10.0"
         | 
| 31 | 
            +
              spec.add_development_dependency "RubyInline", "~>3.12.4"
         | 
| 32 | 
            +
              spec.add_development_dependency "rspec"
         | 
| 33 | 
            +
            end
         | 
    
        data/lib/.DS_Store
    ADDED
    
    | Binary file | 
| @@ -0,0 +1,249 @@ | |
| 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 _kL = 1.0;
         | 
| 13 | 
            +
                  double _kC = 1.0;
         | 
| 14 | 
            +
                  double _kH = 1.0;
         | 
| 15 | 
            +
                  double l1;
         | 
| 16 | 
            +
                  double l2;
         | 
| 17 | 
            +
                  double a1;
         | 
| 18 | 
            +
                  double a2;
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  double r1 = NUM2DBL(rb_hash_aref(color1, rb_str_intern(rb_str_new2("r"))))/255.0;
         | 
| 21 | 
            +
                  double g1 = NUM2DBL(rb_hash_aref(color1, rb_str_intern(rb_str_new2("g"))))/255.0;
         | 
| 22 | 
            +
                  double b1 = NUM2DBL(rb_hash_aref(color1, rb_str_intern(rb_str_new2("b"))))/255.0;
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                  double r2 = NUM2DBL(rb_hash_aref(color2, rb_str_intern(rb_str_new2("r"))))/255.0;
         | 
| 25 | 
            +
                  double g2 = NUM2DBL(rb_hash_aref(color2, rb_str_intern(rb_str_new2("g"))))/255.0;
         | 
| 26 | 
            +
                  double b2 = NUM2DBL(rb_hash_aref(color2, rb_str_intern(rb_str_new2("b"))))/255.0;
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                  double x1 = 0.412453 * r1 + 0.357580 * g1 + 0.180423 * b1;
         | 
| 29 | 
            +
                  double y1 = 0.212671 * r1 + 0.715160 * g1 + 0.072169 * b1;
         | 
| 30 | 
            +
                  double z1 = 0.019334 * r1 + 0.119193 * g1 + 0.950227 * b1;
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                  double x2 = 0.412453 * r2 + 0.357580 * g2 + 0.180423 * b2;
         | 
| 33 | 
            +
                  double y2 = 0.212671 * r2 + 0.715160 * g2 + 0.072169 * b2;
         | 
| 34 | 
            +
                  double z2 = 0.019334 * r2 + 0.119193 * g2 + 0.950227 * b2;
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                  if(y1 <= 0.008856){
         | 
| 37 | 
            +
                    l1 = 903.3 * y1;
         | 
| 38 | 
            +
                    if(x1 <= 0.008856){
         | 
| 39 | 
            +
                      a1 = 500.0 * ((7.787 * x1 + 16.0/116.0) - (7.787 * y1 + 16.0/116.0));
         | 
| 40 | 
            +
                    }else{
         | 
| 41 | 
            +
                      a1 = 500.0 * (cbrt(x1) - (7.787 * y1 + 16.0/116.0));
         | 
| 42 | 
            +
                    }
         | 
| 43 | 
            +
                    if(z1 <= 0.008856){
         | 
| 44 | 
            +
                      b1 = 200 * ((7.787 * y1 + 16.0/116.0) - (7.787 * z1 + 16.0/116.0));
         | 
| 45 | 
            +
                    }else{
         | 
| 46 | 
            +
                      b1 = 200 * ((7.787 * y1 + 16.0/116.0) - cbrt(z1));
         | 
| 47 | 
            +
                    }
         | 
| 48 | 
            +
                  }else{
         | 
| 49 | 
            +
                    l1 = 116.0 * cbrt(y1) - 16.0;
         | 
| 50 | 
            +
                    if(x1 <= 0.008856){
         | 
| 51 | 
            +
                      a1 = 500 * ((7.787 * x1 + 16.0/116.0) - cbrt(y1));
         | 
| 52 | 
            +
                    }else{
         | 
| 53 | 
            +
                      a1 = 500.0 * (cbrt(x1) - cbrt(y1));
         | 
| 54 | 
            +
                    }
         | 
| 55 | 
            +
                    if(z1 <= 0.008856){
         | 
| 56 | 
            +
                      b1 = 200 * (cbrt(y1) - (7.787 * z1 + 16.0/116.0));
         | 
| 57 | 
            +
                    }else{
         | 
| 58 | 
            +
                      b1 = 200 * (cbrt(y1) - cbrt(z1));
         | 
| 59 | 
            +
                    }
         | 
| 60 | 
            +
                  }
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                  if(y2 <= 0.008856){
         | 
| 63 | 
            +
                    l2 = 903.3 * y2;
         | 
| 64 | 
            +
                    if(x2 <= 0.008856){
         | 
| 65 | 
            +
                      a2 = 500 * ((7.787 * x2 + 16.0/116.0) - (7.787 * y2 + 16.0/116.0));
         | 
| 66 | 
            +
                    }else{
         | 
| 67 | 
            +
                      a2 = 500.0 * (cbrt(x2) - (7.787 * y2 + 16.0/116.0));
         | 
| 68 | 
            +
                    }
         | 
| 69 | 
            +
                    if(z2 <= 0.008856){
         | 
| 70 | 
            +
                      b2 = 200 * ((7.787 * y2 + 16.0/116.0) - (7.787 * z2 + 16.0/116.0));
         | 
| 71 | 
            +
                    }else{
         | 
| 72 | 
            +
                      b2 = 200 * ((7.787 * y2 + 16.0/116.0) - cbrt(z2));
         | 
| 73 | 
            +
                    }
         | 
| 74 | 
            +
                  }else{
         | 
| 75 | 
            +
                    l2 = 116.0 * cbrt(y2) - 16.0;
         | 
| 76 | 
            +
                    if(x2 <= 0.008856){
         | 
| 77 | 
            +
                      a2 = 500 * ((7.787 * x2 + 16.0/116.0) - cbrt(y2));
         | 
| 78 | 
            +
                    }else{
         | 
| 79 | 
            +
                      a2 = 500.0 * (cbrt(x2) - cbrt(y2));
         | 
| 80 | 
            +
                    }
         | 
| 81 | 
            +
                    if(z2 <= 0.008856){
         | 
| 82 | 
            +
                      b2 = 200 * (cbrt(y2) - (7.787 * z2 + 16.0/116.0));
         | 
| 83 | 
            +
                    }else{
         | 
| 84 | 
            +
                      b2 = 200 * (cbrt(y2) - cbrt(z2));
         | 
| 85 | 
            +
                    }
         | 
| 86 | 
            +
                  }
         | 
| 87 | 
            +
             | 
| 88 | 
            +
                  double kl = 2.0;
         | 
| 89 | 
            +
                  double k1 = 0.048;
         | 
| 90 | 
            +
                  double k2 = 0.014;
         | 
| 91 | 
            +
             | 
| 92 | 
            +
                  double c1 = sqrt(a1*a1+b1*b1);
         | 
| 93 | 
            +
                  double c2 = sqrt(a2*a2+b2*b2);
         | 
| 94 | 
            +
                  double cdelta = c2 - c1;
         | 
| 95 | 
            +
             | 
| 96 | 
            +
                  double sc = 1.0 + k1 * c1;
         | 
| 97 | 
            +
                  double sh = 1.0 + k2 * c1;
         | 
| 98 | 
            +
             | 
| 99 | 
            +
                  double habdelta = sqrt((a2-a1)*(a2-a1)+(b2-b1)*(b2-b1) - cdelta*cdelta);
         | 
| 100 | 
            +
             | 
| 101 | 
            +
                  double ldiff = (l1 - l2)/kl;
         | 
| 102 | 
            +
                  double adiff = cdelta/sc;
         | 
| 103 | 
            +
                  double bdiff = habdelta/sh;
         | 
| 104 | 
            +
             | 
| 105 | 
            +
                  return DBL2NUM(sqrt(ldiff*ldiff+adiff*adiff+bdiff*bdiff)/50.0);
         | 
| 106 | 
            +
                }'
         | 
| 107 | 
            +
             | 
| 108 | 
            +
                builder.c_singleton 'VALUE ciede2000(VALUE color1, VALUE color2) {
         | 
| 109 | 
            +
                  double pi = 3.1415927;
         | 
| 110 | 
            +
                  double e = 2.7182818;
         | 
| 111 | 
            +
                  double _kL = 1.0;
         | 
| 112 | 
            +
                  double _kC = 1.0;
         | 
| 113 | 
            +
                  double _kH = 1.0;
         | 
| 114 | 
            +
                  double l1;
         | 
| 115 | 
            +
                  double l2;
         | 
| 116 | 
            +
                  double a1;
         | 
| 117 | 
            +
                  double a2;
         | 
| 118 | 
            +
             | 
| 119 | 
            +
                  double r1 = NUM2DBL(rb_hash_aref(color1, rb_str_intern(rb_str_new2("r"))))/255.0;
         | 
| 120 | 
            +
                  double g1 = NUM2DBL(rb_hash_aref(color1, rb_str_intern(rb_str_new2("g"))))/255.0;
         | 
| 121 | 
            +
                  double b1 = NUM2DBL(rb_hash_aref(color1, rb_str_intern(rb_str_new2("b"))))/255.0;
         | 
| 122 | 
            +
             | 
| 123 | 
            +
                  double r2 = NUM2DBL(rb_hash_aref(color2, rb_str_intern(rb_str_new2("r"))))/255.0;
         | 
| 124 | 
            +
                  double g2 = NUM2DBL(rb_hash_aref(color2, rb_str_intern(rb_str_new2("g"))))/255.0;
         | 
| 125 | 
            +
                  double b2 = NUM2DBL(rb_hash_aref(color2, rb_str_intern(rb_str_new2("b"))))/255.0;
         | 
| 126 | 
            +
             | 
| 127 | 
            +
                  double x1 = 0.412453 * r1 + 0.357580 * g1 + 0.180423 * b1;
         | 
| 128 | 
            +
                  double y1 = 0.212671 * r1 + 0.715160 * g1 + 0.072169 * b1;
         | 
| 129 | 
            +
                  double z1 = 0.019334 * r1 + 0.119193 * g1 + 0.950227 * b1;
         | 
| 130 | 
            +
             | 
| 131 | 
            +
                  double x2 = 0.412453 * r2 + 0.357580 * g2 + 0.180423 * b2;
         | 
| 132 | 
            +
                  double y2 = 0.212671 * r2 + 0.715160 * g2 + 0.072169 * b2;
         | 
| 133 | 
            +
                  double z2 = 0.019334 * r2 + 0.119193 * g2 + 0.950227 * b2;
         | 
| 134 | 
            +
             | 
| 135 | 
            +
                  if(y1 <= 0.008856){
         | 
| 136 | 
            +
                    l1 = 903.3 * y1;
         | 
| 137 | 
            +
                    if(x1 <= 0.008856){
         | 
| 138 | 
            +
                      a1 = 500.0 * ((7.787 * x1 + 16.0/116.0) - (7.787 * y1 + 16.0/116.0));
         | 
| 139 | 
            +
                    }else{
         | 
| 140 | 
            +
                      a1 = 500.0 * (cbrt(x1) - (7.787 * y1 + 16.0/116.0));
         | 
| 141 | 
            +
                    }
         | 
| 142 | 
            +
                    if(z1 <= 0.008856){
         | 
| 143 | 
            +
                      b1 = 200 * ((7.787 * y1 + 16.0/116.0) - (7.787 * z1 + 16.0/116.0));
         | 
| 144 | 
            +
                    }else{
         | 
| 145 | 
            +
                      b1 = 200 * ((7.787 * y1 + 16.0/116.0) - cbrt(z1));
         | 
| 146 | 
            +
                    }
         | 
| 147 | 
            +
                  }else{
         | 
| 148 | 
            +
                    l1 = 116.0 * cbrt(y1) - 16.0;
         | 
| 149 | 
            +
                    if(x1 <= 0.008856){
         | 
| 150 | 
            +
                      a1 = 500 * ((7.787 * x1 + 16.0/116.0) - cbrt(y1));
         | 
| 151 | 
            +
                    }else{
         | 
| 152 | 
            +
                      a1 = 500.0 * (cbrt(x1) - cbrt(y1));
         | 
| 153 | 
            +
                    }
         | 
| 154 | 
            +
                    if(z1 <= 0.008856){
         | 
| 155 | 
            +
                      b1 = 200 * (cbrt(y1) - (7.787 * z1 + 16.0/116.0));
         | 
| 156 | 
            +
                    }else{
         | 
| 157 | 
            +
                      b1 = 200 * (cbrt(y1) - cbrt(z1));
         | 
| 158 | 
            +
                    }
         | 
| 159 | 
            +
                  }
         | 
| 160 | 
            +
             | 
| 161 | 
            +
                  if(y2 <= 0.008856){
         | 
| 162 | 
            +
                    l2 = 903.3 * y2;
         | 
| 163 | 
            +
                    if(x2 <= 0.008856){
         | 
| 164 | 
            +
                      a2 = 500 * ((7.787 * x2 + 16.0/116.0) - (7.787 * y2 + 16.0/116.0));
         | 
| 165 | 
            +
                    }else{
         | 
| 166 | 
            +
                      a2 = 500.0 * (cbrt(x2) - (7.787 * y2 + 16.0/116.0));
         | 
| 167 | 
            +
                    }
         | 
| 168 | 
            +
                    if(z2 <= 0.008856){
         | 
| 169 | 
            +
                      b2 = 200 * ((7.787 * y2 + 16.0/116.0) - (7.787 * z2 + 16.0/116.0));
         | 
| 170 | 
            +
                    }else{
         | 
| 171 | 
            +
                      b2 = 200 * ((7.787 * y2 + 16.0/116.0) - cbrt(z2));
         | 
| 172 | 
            +
                    }
         | 
| 173 | 
            +
                  }else{
         | 
| 174 | 
            +
                    l2 = 116.0 * cbrt(y2) - 16.0;
         | 
| 175 | 
            +
                    if(x2 <= 0.008856){
         | 
| 176 | 
            +
                      a2 = 500 * ((7.787 * x2 + 16.0/116.0) - cbrt(y2));
         | 
| 177 | 
            +
                    }else{
         | 
| 178 | 
            +
                      a2 = 500.0 * (cbrt(x2) - cbrt(y2));
         | 
| 179 | 
            +
                    }
         | 
| 180 | 
            +
                    if(z2 <= 0.008856){
         | 
| 181 | 
            +
                      b2 = 200 * (cbrt(y2) - (7.787 * z2 + 16.0/116.0));
         | 
| 182 | 
            +
                    }else{
         | 
| 183 | 
            +
                      b2 = 200 * (cbrt(y2) - cbrt(z2));
         | 
| 184 | 
            +
                    }
         | 
| 185 | 
            +
                  }
         | 
| 186 | 
            +
             | 
| 187 | 
            +
                  double c1 = sqrt(a1*a1+b1*b1);
         | 
| 188 | 
            +
                  double c2 = sqrt(a2*a2+b2*b2);
         | 
| 189 | 
            +
                  double cdelta = c2 - c1;
         | 
| 190 | 
            +
             | 
| 191 | 
            +
                  double lbar = (l1 + l2)/2.0;
         | 
| 192 | 
            +
                  double cbar = (c1 + c2)/2.0;
         | 
| 193 | 
            +
             | 
| 194 | 
            +
                  double lbaradj = (lbar - 50.0)*(lbar - 50.0);
         | 
| 195 | 
            +
                  double cbaradj = sqrt(pow(cbar,7)/(pow(cbar,7)+6103515625.0));
         | 
| 196 | 
            +
             | 
| 197 | 
            +
                  double a1prime = a1 + (a1/2.0) * (1.0-cbaradj);
         | 
| 198 | 
            +
                  double a2prime = a2 + (a2/2.0) * (1.0-cbaradj);
         | 
| 199 | 
            +
             | 
| 200 | 
            +
                  double c1prime = sqrt(a1prime*a1prime+b1*b1);
         | 
| 201 | 
            +
                  double c2prime = sqrt(a2prime*a2prime+b2*b2);
         | 
| 202 | 
            +
                  double cprime = (c1prime + c1prime)/2.0;
         | 
| 203 | 
            +
                  double cprimeadj = sqrt(pow(cprime,7)/(pow(cprime,7)+6103515625.0));
         | 
| 204 | 
            +
                  double cprimedelta = c2prime - c1prime;
         | 
| 205 | 
            +
             | 
| 206 | 
            +
                  double h1;
         | 
| 207 | 
            +
                  double h2;
         | 
| 208 | 
            +
                  if(c1 == 0.0){
         | 
| 209 | 
            +
                    h1 = 0.0;
         | 
| 210 | 
            +
                  }else{
         | 
| 211 | 
            +
                    h1 = fmod(atan2(b1,a1prime),360.0);
         | 
| 212 | 
            +
                  }
         | 
| 213 | 
            +
                  if(c1 == 0.0){
         | 
| 214 | 
            +
                    h2 = 0.0;
         | 
| 215 | 
            +
                  }else{
         | 
| 216 | 
            +
                    h2 = fmod(atan2(b2,a2prime),360.0);
         | 
| 217 | 
            +
                  }
         | 
| 218 | 
            +
                  double h;
         | 
| 219 | 
            +
                  if (fabs(h2 - h1) <= 180.0){
         | 
| 220 | 
            +
                    h = h2 - h1;
         | 
| 221 | 
            +
                  }else if(h2 <= h1){
         | 
| 222 | 
            +
                    h = h2 - h1 + 360.0;
         | 
| 223 | 
            +
                  }else{
         | 
| 224 | 
            +
                    h = h2 - h1 - 360.0;
         | 
| 225 | 
            +
                  }
         | 
| 226 | 
            +
             | 
| 227 | 
            +
                  double hdelta = 2.0 * sqrt(c1prime * c2prime) * sin(h/2.0);
         | 
| 228 | 
            +
                  double hprime = (h1 + h2)/2.0;
         | 
| 229 | 
            +
                  if (fabs(h1 - h2) > 180.0){
         | 
| 230 | 
            +
                    hprime += 180.0;
         | 
| 231 | 
            +
                  }
         | 
| 232 | 
            +
             | 
| 233 | 
            +
                  double t = 1.0 - 0.17*cos(hprime-30.0) + 0.24*cos(2.0*hprime) + 0.32*cos(3.0*hprime + 6.0) - 0.20*cos(4.0*hprime-63.0);
         | 
| 234 | 
            +
             | 
| 235 | 
            +
                  double sl = 1.0 + 0.015 * lbaradj/sqrt(20+lbaradj);
         | 
| 236 | 
            +
                  double sc = 1.0 + 0.045*cprime;
         | 
| 237 | 
            +
                  double sh = 1.0 + 0.015*cprime*t;
         | 
| 238 | 
            +
             | 
| 239 | 
            +
                  double rt = -2.0*cprimeadj*sin(60.0*pow(e,(hdelta-275.0)*(hdelta-275.0)/(-625.0)));
         | 
| 240 | 
            +
             | 
| 241 | 
            +
                  double ldiff = (l1 - l2)/(sl);
         | 
| 242 | 
            +
                  double adiff = cdelta/sc;
         | 
| 243 | 
            +
                  double bdiff = hdelta/sh;
         | 
| 244 | 
            +
                  double rdiff = rt*(cdelta*hdelta)/(sh*sh);
         | 
| 245 | 
            +
             | 
| 246 | 
            +
                  return DBL2NUM(sqrt(ldiff*ldiff+adiff*adiff+bdiff*bdiff+rdiff)/100.0);
         | 
| 247 | 
            +
                }'
         | 
| 248 | 
            +
              end
         | 
| 249 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,118 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: colourdistance
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.0.7
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Orange Seven
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: exe
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2015-07-23 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: bundler
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - ~>
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: '1.10'
         | 
| 20 | 
            +
              type: :development
         | 
| 21 | 
            +
              prerelease: false
         | 
| 22 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 | 
            +
                requirements:
         | 
| 24 | 
            +
                - - ~>
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: '1.10'
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: rake
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - ~>
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '10.0'
         | 
| 34 | 
            +
              type: :development
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - ~>
         | 
| 39 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 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 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 56 | 
            +
              name: rspec
         | 
| 57 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - '>='
         | 
| 60 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            +
                    version: '0'
         | 
| 62 | 
            +
              type: :development
         | 
| 63 | 
            +
              prerelease: false
         | 
| 64 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 | 
            +
                requirements:
         | 
| 66 | 
            +
                - - '>='
         | 
| 67 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 68 | 
            +
                    version: '0'
         | 
| 69 | 
            +
            description: Currently only contains two options, ciede94 and ciede2000, both weighted
         | 
| 70 | 
            +
              to (roughly) a [0,1] scale (actually possible to get very slightly above 1). Will
         | 
| 71 | 
            +
              add more. Both are my own implementations, and ciede94 is probably wrong because
         | 
| 72 | 
            +
              of it.
         | 
| 73 | 
            +
            email:
         | 
| 74 | 
            +
            - theseventhorange@gmail.com
         | 
| 75 | 
            +
            executables: []
         | 
| 76 | 
            +
            extensions: []
         | 
| 77 | 
            +
            extra_rdoc_files: []
         | 
| 78 | 
            +
            files:
         | 
| 79 | 
            +
            - .DS_Store
         | 
| 80 | 
            +
            - .gitignore
         | 
| 81 | 
            +
            - .travis.yml
         | 
| 82 | 
            +
            - Gemfile
         | 
| 83 | 
            +
            - LICENSE.txt
         | 
| 84 | 
            +
            - README.md
         | 
| 85 | 
            +
            - Rakefile
         | 
| 86 | 
            +
            - bin/console
         | 
| 87 | 
            +
            - bin/setup
         | 
| 88 | 
            +
            - colourdistance.gemspec
         | 
| 89 | 
            +
            - lib/.DS_Store
         | 
| 90 | 
            +
            - lib/colourdistance.rb
         | 
| 91 | 
            +
            - lib/colourdistance/version.rb
         | 
| 92 | 
            +
            homepage: 
         | 
| 93 | 
            +
            licenses:
         | 
| 94 | 
            +
            - MIT
         | 
| 95 | 
            +
            metadata:
         | 
| 96 | 
            +
              allowed_push_host: 'TODO: Set to ''http://mygemserver.com'''
         | 
| 97 | 
            +
            post_install_message: 
         | 
| 98 | 
            +
            rdoc_options: []
         | 
| 99 | 
            +
            require_paths:
         | 
| 100 | 
            +
            - lib
         | 
| 101 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 102 | 
            +
              requirements:
         | 
| 103 | 
            +
              - - '>='
         | 
| 104 | 
            +
                - !ruby/object:Gem::Version
         | 
| 105 | 
            +
                  version: '0'
         | 
| 106 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 107 | 
            +
              requirements:
         | 
| 108 | 
            +
              - - '>='
         | 
| 109 | 
            +
                - !ruby/object:Gem::Version
         | 
| 110 | 
            +
                  version: '0'
         | 
| 111 | 
            +
            requirements: []
         | 
| 112 | 
            +
            rubyforge_project: 
         | 
| 113 | 
            +
            rubygems_version: 2.0.14
         | 
| 114 | 
            +
            signing_key: 
         | 
| 115 | 
            +
            specification_version: 4
         | 
| 116 | 
            +
            summary: Measures the difference (as a distance between colors in lab space) between
         | 
| 117 | 
            +
              colours. Takes rgb input. Will add support for xyz and lab around version 1.0.
         | 
| 118 | 
            +
            test_files: []
         |