xxxxxxxxxx
73
function setup() {
createCanvas(3000, 3000);
colorMode(HSL, 100, 100, 100, 1);
let fillHue = random(100);
background(90);
stroke(20);
strokeWeight(0.5);
let scl = 75;
let gridW = width / scl;
let gridH = height / scl;
let size = (scl * 0.6) / 2;
let x = scl / 2;
let y = scl / 2;
for (let i = 0; i < gridH; i++) {
for (let j = 0; j < gridW; j++) {
let acc = map(i + j, 0, gridW + gridH - 2, 1, 0.75);
let rounds = map(i + j, 0, gridW + gridH - 2, 0.1, 5);
let fillCol = null;
if (random() < 0.9) {
let hue = (fillHue + random(-15, 15)) % 100;
fillCol = color(hue, 55, 55, 0.5);
}
for (let i = 0; i < rounds; i++) {
drawnCircle(x, y, size, acc, fillCol);
}
x += scl;
}
x = scl / 2;
y += scl;
}
save("handdrawnCircles");
}
function draw() {}
function polygon(x, y, radius, npoints) {
let angle = TWO_PI / npoints;
let vertices = [];
for (let a = 0; a < TWO_PI; a += angle) {
let sx = x + cos(a) * radius;
let sy = y + sin(a) * radius;
vertices.push(createVector(sx, sy));
}
return vertices;
}
function drawnCircle(xPos, yPos, r, acc, fillCol = null) {
let points = polygon(xPos, yPos, r, 20);
points.push(points[0], points[1]);
let diviation = r * (1 - acc);
for (let i = 0; i < points.length; i++) {
points[i].x += random(-diviation, diviation);
points[i].y += random(-diviation, diviation);
}
let c = new Curve(points, 0.25);
// if (fillCol) {
// fill(fillCol);
// beginShape();
// for (let i = 0; i < c.lines.length; i++) {
// vertex(c.lines[i].p1.x, c.lines[i].p1.y);
// vertex(c.lines[i].p2.x, c.lines[i].p2.y);
// }
// endShape();
// }
c.show();
}