ソースを参照

Randomize initial color for markers to give more variation

Kirk Trombley 3 年 前
コミット
fc36ce436b

+ 2 - 2
client/src/hooks/useMarkersFromGuesses/getColorGenerator.js

@@ -2,8 +2,8 @@
 // https://martin.ankerl.com/2009/12/09/how-to-create-random-colors-programmatically/
 const goldenRatioConj = 0.618033988749895;
 
-const getColorGenerator = () => {
-  let h = 0;
+const getColorGenerator = (hInit = null) => {
+  let h = hInit ?? Math.random();
   const nextColor = () => {
     const h6 = h * 6;
     h += goldenRatioConj;