xxxxxxxxxx
36
// See "Events -> Mouse"
// https://p5js.org/reference/
let size = 25;
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
// Change color if mouse button is pressed
if (mouseIsPressed) {
if (mouseButton === LEFT) {
stroke(255, 0, 0);
} else if (mouseButton === RIGHT) {
stroke(0, 255, 0);
} else if (mouseButton === CENTER) {
stroke(0, 0, 255);
}
} else {
stroke(0, 0, 0);
}
// Draw a circle wherever the mouse is.
circle(mouseX, mouseY, size);
}
// Change circle size if mousewheel scrolled
function mouseWheel(event) {
size += event.delta * 5;
//uncomment to block page scrolling
//return false;
}