Skip to content

Instantly share code, notes, and snippets.

@takawo
Last active May 24, 2022 11:10
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save takawo/94e54399ff5ffa868c28efebb61e086a to your computer and use it in GitHub Desktop.
Save takawo/94e54399ff5ffa868c28efebb61e086a to your computer and use it in GitHub Desktop.
function setup() {
createCanvas(800, 800);
angleMode(DEGREES);
}
function draw() {
background((95 / 100) * 255);
push();
translate(width / 2, height / 2);
let ratio = 0.01;
let angle_num = 10;
for (let i = 0; i < 10000; i++) {
let bool = random() > 0.5;
let angle =
(int(random(angle_num)) * 360) / angle_num +
((recursiveRandom(3, bool) - 0.5) * 360) / angle_num / 2;
let n = recursiveRandom(random(0, 5), bool);
let r = 200 * n;
let x = cos(angle) * r * (bool ? 1 - ratio : 1 + ratio);
let y = sin(angle) * r * (bool ? 1 - ratio : 1 + ratio);
strokeWeight(2 - abs(n - 1) * 2);
point(x, y);
}
pop();
noLoop();
}
function recursiveRandom(count, bool = true) {
let n = 1;
while (count > 0) {
n *= random();
count--;
}
return bool ? 1 - n : 1 + n;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment