You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+37-30Lines changed: 37 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,9 +2,9 @@
2
2
3
3
Have you ever thought to yourself, "man, I really wish I could make this plot a random color so debugging is less boring"?
4
4
5
-
Or maybe: "I need 20 different colors for my chart but I don't want them to look too similar"
5
+
Alternatively, "I need 20 different colors for my chart, but I don't want them to look too similar."
6
6
7
-
Well congratulations, you've just found the package for that. Just simply do:
7
+
Congratulations! You've just located the right package/library! Just do:
8
8
9
9
```python
10
10
import random_color_hex asRCH
@@ -47,7 +47,7 @@ Each line gets its own random color
47
47
48
48
## The Cool Part: Smart Color Separation
49
49
50
-
Here's where it gets interesting - this library can make sure your colors are actually different from each other:
50
+
This library is special in that it uses Gaurav Sharma's 2001 paper CIEDE2000 to calculate the distance between colors actually ***looks***different versus just being a random color. (See below for continued discussion on this topic)
51
51
52
52
```python
53
53
import random_color_hex asRCH
@@ -59,15 +59,21 @@ color3=RCH.main(HowDifferentShouldColorsBe='L') # Different from both
59
59
```
60
60
61
61
The `HowDifferentShouldColorsBe` parameter controls the minimum distance between colors:
62
-
-`'s'` (small) - Slightly different (default)
63
-
-`'m'` (medium) - Clearly different
62
+
-`'s'` (small) - Slightly different
63
+
-`'m'` (medium) - Clearly different (default)
64
64
-`'l'` (large) - Very different
65
65
-`'sl'` (super large) - Extremely different
66
66
67
67
This is perfect when you need multiple colors that won't blend together
68
68
69
69
---
70
70
71
+
For most people, this will be enough no problems. However, for individuals who are using dozens of colors in one run of a program, trying to get colors that are distinct becomes less relevant than getting colors out. This also has a backup to allow for standard RGB generation. This ensures that the program never gets stuck trying to generate a "unique" color forever if you really just want 50000 colors.
72
+
73
+
If the program gets stuck, it will let you know and request you lower your separation. If you don't, it will assume you want just a high amount of colors and will generate them with no separation. No human interaction is required for this!
74
+
75
+
Each color is generated using the secrets module as well, meaning the colors are near true random.
0 commit comments