Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Delta E Perception
- <= 1.0 Not perceptible by human eyes.
- 1 - 2 Perceptible through close observation.
- 2 - 10 Perceptible at a glance.
- 11 - 49 Colors are more similar than opposite
- 100 Colors are exact opposite
- status
- 0 Exact Match
- 2 Not perceptible by human eyes.
- 4 Perceptible through close observation.
- 8 Perceptible at a glance.
- 16 Colors are exact opposite
- */
- function matchColor (CIELab1, ColorCollection) {
- const delta = deltaE1994(CIELab1, ColorCollection.cieLab)
- if (delta === 0) {
- return {
- status: 1,
- name: ColorCollection.name,
- hex: ColorCollection.hex,
- delta,
- message: 'Exact Match'
- }
- } else if (delta > 0 && delta <= 1) {
- return {
- status: 2,
- name: ColorCollection.name,
- hex: ColorCollection.hex,
- delta,
- message: 'Not perceptible by human eyes'
- }
- } else if (delta > 1 && delta < 2) {
- return {
- status: 4,
- name: ColorCollection.name,
- hex: ColorCollection.hex,
- delta,
- message: 'Perceptible through close observation'
- }
- } else if (delta >= 2 && delta < 10) {
- return {
- status: 8,
- name: ColorCollection.name,
- hex: ColorCollection.hex,
- delta,
- message: 'Perceptible at a glance'
- }
- }
- return {
- status: -1,
- delta,
- message: 'No Color match found'
- }
- }
Add Comment
Please, Sign In to add comment