瀏覽代碼

Randomize initial color for markers to give more variation

Kirk Trombley 3 年之前
父節點
當前提交
fc36ce436b
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      client/src/hooks/useMarkersFromGuesses/getColorGenerator.js

+ 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;