0.0
No commit activity in last 3 years
No release in over 3 years
Match the threshold of a color against a collection of colors.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 10.0
~> 3.1

Runtime

 Project Readme

ColorProximity

Build Status

Given a threshold and a collection of colors, you'll be able to determine how close a given color is to matching a list.

A gem that implements a CIEDE2000 color-difference formula is the main backend used.

Usage

require 'color-proximity'
cp = ColorProximity.new(0.5, ['000000'])
cp.past_threshold?('000000') # [false, ['000000']]

cp.collection = (['ffffff'])
cp.past_threshold?('000000') # [true]

cp.collection = (['000001', '000002', 'ffffff'])
cp.thresholds('000003') # [0.00832, 0.00412, 0.99948]

A failure case returns an array with two elements: false, and the collection of colors that failed the threshold. Success cases return an array with one element: true. This is designed to make it easy to call .first on the result to validate it.

Installation

Add this line to your application's Gemfile:

gem 'color-proximity'

And then execute:

$ bundle

Or install it yourself as:

$ gem install color-proximity