F1 = 102 / N, F2 = 54 / N;
{clr: "darkorange", f: 1},
{clr: "darkred", f: 0.2},
createCanvas(297 * SCL, 210 * SCL);
const seed = ~~random(1234567);
console.log(`seed: ${seed}`)
const t = frameCount / 123;
svgGrps = Array(pal.length); for (let i = 0; i < pal.length; i++) svgGrps[i] = '';
console.log("draw() 1", svgGrps);
let hClrIdxs = [], vClrIdxs = [];
if (true || random() < 0.5) {
for (let i = 0; i < pal.length; i++) {
drawLines(false, t, hClrIdxs);
drawLines(true, t, vClrIdxs);
console.log("draw() 2", svgGrps);
function mousePressed() {
if (mouseButton !== RIGHT && mouseX > width*0.1 && mouseX < width*0.9) {
function drawLines(hv = true, t = 0, clrIdxs = []) {
let H = height, W = width;
for (let y = ~~(N / 2); y < H; y += N) {
let x = noise(y / NF, t) * -10 * N;
if (clrIdxs && clrIdxs.length > 0) {
clrIdx = ~~(random()**2 * clrIdxs.length);
clrIdx = ~~random(pal.length);
const len = noise(y / NF, x / NF, t) * F1 * N;
const pad = noise(x / NF, y / NF, t) * F2 * N;
svgLine(x, y, x + len, y, clrIdx);
svgLine(y, x + len, y, x, clrIdx);
function svgLine(x1, y1, x2, y2, clr, prec = 2) {
x1 = constrain(x1, 0, width);
y1 = constrain(y1, 0, height);
x2 = constrain(x2, 0, width);
y2 = constrain(y2, 0, height);
svgGrps[clr] += `<line x1="${nf(x1,0,prec)}" y1="${nf(y1,0,prec)}" x2="${nf(x2,0,prec)}" y2="${nf(y2,0,prec)}" />\n`;
saveSvg("epi_dashed_grid.svg.txt");
function saveSvg(file_name) {
console.log("saveSvg()", svgGrps);
let svgAll = `<svg width="${width}" height="${height}" xmlns="http://www.w3.org/2000/svg">\n`;
for (let i = 0; i < svgGrps.length; i++) {
const svgGr = svgGrps[i];
svgAll += `<g id="${pal[i]}" stroke="${pal[i]}" stroke-width="1" fill="none">\n` + svgGr + `</g>\n`;
save(svgAll.split("\n"), file_name);