xxxxxxxxxx
82
var options = [
"ORANGE",
"RISOFEDERALBLUE",
"BLACK",
"TEAL",
]
let ink1,ink2;
function setup() {
createCanvas(windowWidth * .9, windowHeight * .9); // Create SVG Canvas
ink1 = round(random(0,options.length-1));
console.log(options[ink1]);
ink2 = round(random(0,options.length-1));
console.log(options[ink2]);
colors = [
new Riso(options[ink1]),
new Riso(options[ink2])];
if (windowHeight >= windowWidth) {
jokagbo(50, 50, 0, 0, windowWidth, windowWidth);
} else {
jokagbo(50, 50, 0, 0, windowHeight, windowHeight);
}
drawRiso();
}
function mousePressed() {
ink1 = round(random(0,options.length-1));
// console.log(options[ink1]);
ink2 = round(random(0,options.length-1));
// console.log(options[ink2]);
colors = [
new Riso(options[ink1]),
new Riso(options[ink2])];
clearRiso();
background(255);
if (windowHeight >= windowWidth) {
jokagbo(50, 50, 0, 0, windowWidth, windowWidth);
} else {
jokagbo(50, 50, 0, 0, windowHeight, windowHeight);
}
drawRiso();
}
// recursion happens in here
function jokagbo(minWidth, minHeight, startX, startY, endX, endY) {
var width = endX - startX;
var height = endY-startY;
if (width > minWidth && height > minHeight) {
var centerX = random(startX + (width * .25), endX - (width * .25));
var centerY = random(startY + (height * .25), endY - (height * .25));
quads(startX, startY, centerX, centerY, endX, endY);
jokagbo(minWidth, minHeight, startX, startY, centerX, centerY); // NW
jokagbo(minWidth, minHeight, centerX, startY, endX, centerY); // NE
jokagbo(minWidth, minHeight, startX, centerY, centerX, endY); // SW
jokagbo(minWidth, minHeight, centerX, centerY, endX, endY); // SE
}
}
function quads(x1, y1, midX, midY, x2, y2) {
colors[0].fill(random(100));
colors[1].fill(random(100));
colors[0].strokeWeight(2);
colors[1].strokeWeight(2);
colors[0].quad(x1, y1, midX, y1, midX, midY, x1, midY) // NW
colors[1].quad(midX, midY, x2, midY, x2, y2, midX, y2) // SE
}