MCPcopy Index your code
hub / github.com/codrops/RainEffect / random

Function random

src/random.js:1–17  ·  view source on GitHub ↗
(from=null,to=null,interpolation=null)

Source from the content-addressed store, hash-verified

1export function random(from=null,to=null,interpolation=null){
2 if(from==null){
3 from=0;
4 to=1;
5 }else if(from!=null && to==null){
6 to=from;
7 from=0;
8 }
9 const delta=to-from;
10
11 if(interpolation==null){
12 interpolation=(n)=>{
13 return n;
14 }
15 }
16 return from+(interpolation(Math.random())*delta);
17}
18export function chance(c){
19 return random()<=c;
20}

Callers 7

initFunction · 0.90
flashFunction · 0.90
updateRainFunction · 0.90
clearDropsFunction · 0.90
updateDropletsFunction · 0.90
updateDropsFunction · 0.90
chanceFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected