📦 CIEDE2000 color difference algorithm
Samandar Ravshanov
Posted on August 1, 2019
from functorflow import ff
# ------ Returns the closest color ---------
color = { 'R': 255, 'G': 1, 'B': 30 }
# red, green, blue
palette = [ {'R': 255, 'G': 0, 'B': 0 },
{'R': 0, 'G': 255, 'B': 0 },
{'R': 0, 'G': 0, 'B': 255} ]
print(ff('color-diff').closest(color, palette))
# {R: 255, G: 0, B: 0 }, red
# ------ Return the most different color -----------
color = { 'R': 255, 'G': 255, 'B': 255 };
# black, white
palette = [ {'R': 0, 'G': 0, 'B': 0 }, {'R': 255, 'G': 255, 'B': 255 } ];
print(ff('color-diff').furthest(color, palette))
# {'R': 0, 'G': 0, 'B': 0 }, black
💖 💪 🙅 🚩
Samandar Ravshanov
Posted on August 1, 2019
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
replit 📦 Transform a camelized/dasherized/underscored/etc string into a readable string
August 1, 2019