xxxxxxxxxx
42
function setup() {
createCanvas(400, 400);
frameRate(1);
angleMode(DEGREES);
}
function draw() {
background(220);
let d = 5;
//wonky(200, 200, 7, 100);
for (let x=width/d/2; x<width; x+=(width/d)) {
for (let y=(height/d)/2; y<height; y+=(height/d)) {
wonky(x, y, 4, width/d/3, true);
}
}
}
function wonky(x, y, pts, r, scribble) {
let ang = 360 / pts;
if (scribble) ang = 360 / (pts + 1);
let offsets = [];
for (let i=0; i<pts; i++) {
let xoff = round(random(r * -0.3, r * 0.3));
let yoff = round(random(r * -0.3, r * 0.3))
offsets.push([xoff, yoff]);
}
console.log(offsets);
push();
translate(x, y);
beginShape();
//curveVertex(r, 0)
for (let i=0; i<pts * 4; i++) {
//curveTightness(5)
curveVertex(cos(i * ang) * r + offsets[i % offsets.length][0], sin(i * ang) * r + offsets[i % offsets.length][1]);
}
endShape();
pop();
}