Skip to content

Instantly share code, notes, and snippets.

@seanlynch
Created September 20, 2018 22:25
Show Gist options
  • Save seanlynch/7ea2ec6a7d98735f285910a724116d28 to your computer and use it in GitHub Desktop.
Save seanlynch/7ea2ec6a7d98735f285910a724116d28 to your computer and use it in GitHub Desktop.
let grid = 40;
let lastrand = 0;
function setup() {
createCanvas(400, 400);
ellipseMode(CORNER);
}
function seed(x) {
lastrand = x;
}
function myrand(x) {
// This is probably slow in JS
lastrand = (lastrand * 1103515245 + 12345) % 0x7fffffff
return lastrand % x;
}
function draw() {
background(220);
seed(42);
for (let i = 0; i < grid; i++) {
for (let j = 0; j < grid; j++) {
fill(myrand(255));
ellipse(i * (width/grid),
j * (height/grid),
10, 10);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment