xxxxxxxxxx
40
let bg;
let stickyNotes = [];
function setup() {
bg = loadImage('cokboard2.jpg');
createCanvas(900, 700);
}
function draw() {
background(bg);
// Display all the sticky notes
for (let note of stickyNotes) {
note.display();
}
}
function mouseClicked() {
// Check if the click is within the canvas boundaries
if (mouseX >= 0 && mouseX <= width && mouseY >= 0 && mouseY <= height) {
// Create a new sticky note at the click position
stickyNotes.push(new StickyNote(mouseX, mouseY, color(255, 255, 153))); // Yellow color
}
}
class StickyNote {
constructor(x, y, color) {
this.x = x;
this.y = y;
this.color = color;
}
display() {
// Draw the sticky note
fill(this.color);
rect(this.x, this.y, 100, 100);
}
}