mouse
v0.0.6mouseX
GlobalThe x mouse coordinate
createWindow(400, 400);
function draw()
background(51);
line(mouseX, 0, mouseX, height);
end
mouseY
GlobalThe y mouse coordinate
createWindow(400, 400);
function draw()
background(51);
line(0, mouseY, width, mouseY);
end
mouseIsPressed
GlobalIs true
when the mouse is pressed, is false
when it's not
mousePressed(button);
EventCalled when a mouse button is pressed.
Arguments
button
The pressed mouse button
In the following example, the circle's size increases when the user clicks the mouse.
size = 0;
function setup()
createWindow(400, 400);
end
function draw()
background(51);
circle(mouseX, mouseY, size);
end
-- Increase circle size when mouse pressed
function mousePressed()
size = size + 1;
end
mouseReleased(button);
EventCalled when a mouse button is released.
Arguments
button
The released mouse button
In the following example, the circle's size increases when the user clicks the mouse.
size = 32;
function setup()
createWindow(400, 400);
end
function draw()
background(51);
circle(mouseX, mouseY, size);
end
-- Set larger circle size
function mousePressed()
size = 64;
end
-- Reset size
function mouseReleased()
size = 32;
end