xxxxxxxxxx
// Organic Illusion with Animation in p5.js
// Based on "Organic Illusion" by William Kolomyjec / https://www.sfmoma.org/artwork/2015.5/
// Adapted from Processing to p5.js by Kazoops https://openprocessing.org/user/211463
// epi: correction unit calculation, possibility define res and highlight
let williams = [];
let rows = 5, columns = 3, res = 7, unit = 150;
let svgGrps;
function setup() {
createCanvas(unit * columns, unit * rows);
frameRate(60);
background("tan");
// william circles
for (let i = 0; i < columns; i++) {
const highlight = ~~random(res);
for (let j = 0; j < rows; j++) {
williams.push(new William(createVector(i * unit, j * unit), random(TWO_PI), res, highlight));
}
}
}
function draw() {
background("tan");
stroke(32);
// svg grps for different pen colors
svgGrps = [
{clr: "black", str: ""},
{clr: "darkred", str: ""},
]
// updating and drawing cells
for (let w of williams) {
w.update();
w.display();
}
}
function keyPressed() {
if (key == "s" || key == "S") saveSvg("epi_william.svg.txt");
}