xxxxxxxxxx
87
let razParams = [];
let fliper;
let howMany;
function setup() {
noLoop();
createCanvas(400, 400,SVG);
noStroke();
rectMode(CORNER);
angleMode(DEGREES);
howMany = windowWidth/4;
for (let i = 0; i < howMany; i++) {
if (random > .5) {
flipper = true;
} else {
flipper = false
}
let myParams = [
random(width),
random(height),
// map(i,0,howMany,0,width),
// map(i,0,howMany,0,height),
// random(80, 240),
// random(90, 250),
random(width/5,width/2),
random(height/5,height/2),
random(7, 38),
flipper,
random(.3, .7),
random(height/220, height/200)
]
// x, y, l, h, lineCount, flip, angle, overlap
razParams.push(myParams);
}
}
function draw() {
background(220);
makeRazzle(0, 0, width*2, height, 35, true, .6, 1.6);
for(let i=0; i<razParams.length;i++){
cur = razParams[i]
makeRazzle(cur[0],cur[1],cur[2],cur[3],cur[4],cur[5],cur[6],cur[7])
}
save("mySVG.svg"); // give file name
}
function makeRazzle(x, y, l, h, lineCount, flip, angle, overlap) {
let lineHeight = h / lineCount;
yPos = y;
for (let i = 0; i < lineCount; i++) {
if (flip) {
fill(248)
} else {
fill(20)
}
rotate(angle);
rect(x, yPos, l, lineHeight * overlap)
yPos += lineHeight;
flip = !flip;
}
}