xxxxxxxxxx
29
function heart(x0, y0, w) {
let xRadius = w / 2;
let ellipseDiam = xRadius * 1.25;
let ellipseOffsetX = (2 / 9) * w;
let ellipseOffsetY = (3 / 20) * w;
let triY = 1.2 * xRadius;
ellipse(x0 - ellipseOffsetX, y0 - ellipseOffsetY, ellipseDiam);
ellipse(x0 + ellipseOffsetX, y0 - ellipseOffsetY, ellipseDiam);
triangle(x0 - xRadius, y0, x0 + xRadius, y0, x0, y0 + triY);
}
function setup() {
createCanvas(windowWidth, windowHeight);
noLoop();
}
function draw() {
background(220, 10, 120);
fill(250, 190, 0);
noStroke();
for (let y = 50; y < height; y += 50) {
for (let x = 50; x < width; x += 50) {
heart(x, y, 40);
}
}
}