Guest User

Untitled

a guest
Oct 22nd, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. /*
  2. Delta E Perception
  3. <= 1.0 Not perceptible by human eyes.
  4. 1 - 2 Perceptible through close observation.
  5. 2 - 10 Perceptible at a glance.
  6. 11 - 49 Colors are more similar than opposite
  7. 100 Colors are exact opposite
  8. status
  9. 0 Exact Match
  10. 2 Not perceptible by human eyes.
  11. 4 Perceptible through close observation.
  12. 8 Perceptible at a glance.
  13. 16 Colors are exact opposite
  14. */
  15.  
  16. function matchColor (CIELab1, ColorCollection) {
  17. const delta = deltaE1994(CIELab1, ColorCollection.cieLab)
  18. if (delta === 0) {
  19. return {
  20. status: 1,
  21. name: ColorCollection.name,
  22. hex: ColorCollection.hex,
  23. delta,
  24. message: 'Exact Match'
  25. }
  26. } else if (delta > 0 && delta <= 1) {
  27. return {
  28. status: 2,
  29. name: ColorCollection.name,
  30. hex: ColorCollection.hex,
  31. delta,
  32. message: 'Not perceptible by human eyes'
  33. }
  34. } else if (delta > 1 && delta < 2) {
  35. return {
  36. status: 4,
  37. name: ColorCollection.name,
  38. hex: ColorCollection.hex,
  39. delta,
  40. message: 'Perceptible through close observation'
  41. }
  42. } else if (delta >= 2 && delta < 10) {
  43. return {
  44. status: 8,
  45. name: ColorCollection.name,
  46. hex: ColorCollection.hex,
  47. delta,
  48. message: 'Perceptible at a glance'
  49. }
  50. }
  51. return {
  52. status: -1,
  53. delta,
  54. message: 'No Color match found'
  55. }
  56. }
Add Comment
Please, Sign In to add comment