MCPcopy Index your code
hub / github.com/davidmerfield/randomColor / randomWithin

Function randomWithin

randomColor.js:314–330  ·  view source on GitHub ↗
(range)

Source from the content-addressed store, hash-verified

312 }
313
314 function randomWithin(range) {
315 if (seed === null) {
316 //generate random evenly destinct number from : https://martin.ankerl.com/2009/12/09/how-to-create-random-colors-programmatically/
317 var golden_ratio = 0.618033988749895;
318 var r = Math.random();
319 r += golden_ratio;
320 r %= 1;
321 return Math.floor(range[0] + r * (range[1] + 1 - range[0]));
322 } else {
323 //Seeded random algorithm from http://indiegamr.com/generate-repeatable-random-numbers-in-js/
324 var max = range[1] || 1;
325 var min = range[0] || 0;
326 seed = (seed * 9301 + 49297) % 233280;
327 var rnd = seed / 233280.0;
328 return Math.floor(min + rnd * (max - min));
329 }
330 }
331
332 function HSVtoHex(hsv) {
333 var rgb = HSVtoRGB(hsv);

Callers 3

pickHueFunction · 0.85
pickSaturationFunction · 0.85
pickBrightnessFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…