xxxxxxxxxx
47
let gridSize = 8;
function toCartesian(r, theta) {
return [r*cos(theta), r*sin(theta)];
}
function drawLetter() {
let angles = [];
for (let i = 0; i < int(random(5, 15)); i++) {
angles.push(PI/12 * int(random(12)));
}
beginShape();
for (let i = 0; i < angles.length; i++) {
let xy = toCartesian(50, angles[i]);
curveVertex(xy[0], xy[1]);
}
endShape();
}
function setup() {
createCanvas(600, 600);
}
function draw() {
background(220);
push();
translate(width/(gridSize*2), height/(gridSize*2));
for (let i = 0; i < gridSize; i++) {
for (let j = 0; j < gridSize; j++) {
push();
translate(i * (width/gridSize), j * (height/gridSize));
scale(0.5);
strokeWeight(2);
stroke(0);
noFill();
drawLetter();
pop();
}
}
pop();
noLoop();
}
function mousePressed() {
draw();
}