repl.it
@functorflow/

color-diff

Python

📦 CIEDE2000 color difference algorithm

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from functorflow import ff

# CIEDE2000 color difference algorithm

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} ]

r = ff.color_diff.closest(color, palette)

print(r)
# {R: 255, G: 0, B: 0 }, red


color = { 'R': 255, 'G': 255, 'B': 255 };
# black, white
palette = [ {'R': 0, 'G': 0, 'B': 0 }, {'R': 255, 'G': 255, 'B': 255 } ];

r = ff.color_diff.furthest(color, palette)

print(r)
# {'R': 0, 'G': 0, 'B': 0 }, black