xxxxxxxxxx
let currentDate;
function setup() {
createCanvas(800, 100);
currentDate = new Date();
background(220);
noLoop();
}
function draw() {
background(220);
let daysInMonth = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 0).getDate();
let elementWidth = width / daysInMonth;
for (let day = 1; day <= daysInMonth; day++) {
let x = (day - 1) * elementWidth;
if (day === currentDate.getDate()) {
fill(255, 0, 0);
} else {
fill(0);
}
rect(x, 30, elementWidth, 40);
fill(255);
textSize(16);
textAlign(CENTER, CENTER);
text(day, x + elementWidth / 2, 50);
}
}