let isoCubes, S, noiseFn;
const D = 4, SCL = 3, MAR = 20;
createCanvas(210 * SCL, 297 * SCL);
noiseFn = mynoise.perlin3;
S = (~~(min(width, height) / 3) / D) * D;
{ x: width-MAR, y: MAR },
{ x: width-MAR, y: height-MAR },
{ x: MAR, y: height-MAR },
for (let i = 0; i < 5; i++) {
const cx = random(100, width-100);
const cy = random(100, height-100);
const sze = random(0.35, 1.25) * S;
isoCubes.push(new IsoCube(cx, cy, sze, D));
isoCubes.push(new IsoCube(100, 110, 100, D));
isoCubes.push(new IsoCube(300, 110, 100, D));
isoCubes.push(new IsoCube(500, 110, 100, D));
isoCubes.push(new IsoCube(000, 310, 100, D));
isoCubes.push(new IsoCube(200, 310, 100, D));
isoCubes.push(new IsoCube(400, 310, 100, D));
isoCubes.push(new IsoCube(600, 310, 100, D));
isoCubes.push(new IsoCube(100, 510, 100, D));
isoCubes.push(new IsoCube(300, 510, 100, D));
isoCubes.push(new IsoCube(500, 510, 100, D));
isoCubes.push(new IsoCube(000, 710, 100, D));
isoCubes.push(new IsoCube(200, 710, 100, D));
isoCubes.push(new IsoCube(400, 710, 100, D));
isoCubes.push(new IsoCube(600, 710, 100, D));
isoCubes.push(new IsoCube(100, 910, 100, D));
isoCubes.push(new IsoCube(300, 910, 100, D));
isoCubes.push(new IsoCube(500, 910, 100, D));
for (const ic of isoCubes) {
for (let i = 0; i < random(3, 6); i++) {
const cx = random(100, width-100);
const cy = random(100, height-100);
const sze = random(0.35, 1.25) * S / 1.5;
function drawCircle(cx, cy, r) {
svgCircles += `<g fill="none" stroke="black" stroke-width="1">\n`;
for (let i = 0, lx, ly; i < 50; i++) {
const x = cos(a) * r + cx;
const y = sin(a) * r + cy;
if (i > 0) clipLine({x: lx, y: ly}, {x, y}, boundaryPoints);
function drawNoiseGrid() {
const t = frameCount / d;
for (let y = 0; y < height; y += S) {
for (let x = 0; x < width; x += S) {
const n = noiseFn(x/d, y/d, t);
function mousePressed() {
if (mouseButton != RIGHT && mouseX > width*0.1 && mouseY < width*0.9) {
saveSvg("epi_iso_waves.svg.txt");
function saveSvg(file_name) {
let svgAll = `<svg width="${width}" height="${height}" xmlns="http://www.w3.org/2000/svg">\n`;
for (const ic of isoCubes) {
svgAll += `<g fill="none" stroke="black" stroke-width="1">\n`;
for (const sh of ic.shapes) {
clipPts(sh, boundaryPoints, {point: {x: ic.pos.x, y: ic.pos.y}, angle: ic.detail})
save(svgAll.split("\n"), file_name);