xxxxxxxxxx
133
const num = 10;
let s;
let colours;
let methods;
let seed = 0;
function setup() {
createCanvas(900, 900);
s = width/num;
colours = [
// NEON
// color(0, 255, 255),
// color(255, 255, 0),
// color(255, 0, 255),
// DUSK
color('#fbbbad'),
color('#ee8695'),
color('#4a7a96'),
// ICE CREAM
// color('#ffc1cf'),
// color('#e8ffb7'),
// color('#e2a0ff'),
// color('#c4f5fc'),
// color('#b7ffd8'),
];
methods = [
quarter,
quadQuarters,
bigCircle,
lines,
// checker,
// bigSquare,
]
noLoop();
noStroke();
randomSeed(seed);
}
function draw() {
clear();
for(let i = 0; i < width; i += s) {
for(let j = 0; j < height; j += s) {
drawCell(i + s/2, j + s/2);
}
}
}
function keyReleased() {
if(key === " ") {
seed += 1;
randomSeed(seed);
print(seed);
draw();
}
}
function drawCell(x, y) {
push();
translate(x, y);
randomMethod();
pop();
}
function drawQuarter(x, y, r) {
push();
translate(x, y);
randomRotation();
randomColour();
arc(-r/2, -r/2, r * 2, r * 2, 0, HALF_PI);
pop();
}
function quarter() {
drawQuarter(0, 0, s);
}
function quadQuarters() {
drawQuarter(-s/4, -s/4, s/2);
drawQuarter(s/4, -s/4, s/2);
drawQuarter(-s/4, s/4, s/2);
drawQuarter(s/4, s/4, s/2);
}
function bigCircle() {
randomColour();
circle(0, 0, s);
}
function lines() {
randomRotation();
randomColour();
let n = 3;
let l = s/n;
for(let i = 0; i < 3; i ++) {
rect(-s/2, ((i * l) + l/2) - s/2, s, l/2);
}
}
function checker() {
randomRotation();
randomColour();
square(-s/2, -s/2, s/2);
randomColour();
square(0, 0, s/2);
}
function bigSquare() {
fill(randomColour());
square(-s/2, -s/2, s);
}
function randomMethod() {
let n = floor(random(methods.length));
methods[n]();
}
function randomRotation() {
rotate(floor(random(4)) * HALF_PI);
}
function randomColour() {
let n = floor(random(colours.length));
fill(colours[n]);
}