You are on page 1of 1

Poisson disc distribution

function sample() {
var bestCandidate, bestDistance = 0;
for (var i = 0; i < numCandidates; ++i) {
var c = [Math.random() * width, Math.random() * height],
d = distance(findClosest(samples, c), c);
if (d > bestDistance) {
bestDistance = d;
bestCandidate = c;
}
}
return bestCandidate;
}

Shuffling - FisherYates
function shuffle(array) {
var n = array.length, t, i;
while (n) {
i = Math.random() * n-- | 0; // 0 i < n
t = array[n];
array[n] = array[i];
array[i] = t;
}
return array;
}

-221.72, -324.46, 22.47, 0.00

0x971c93421 big screens script

You might also like