The mousePressed() function is called by p5 every time the mouse is pressed.
function mousePressed() {
// set random fill color
}
Change the size of the brush (diameter) using the keyboard. If + is pressed the diameter is increased and if - is pressed the diameter is decreased. You can use the keyPressed() function for that. p5 will call the keyPressed() function.
function keyPressed() {
if(key === '+') {
// increase diameter
} else if (...) {
// decrease diameter
}
}
setup()
functionBonus
The
mousePressed()
function is called by p5 every time the mouse is pressed.Change the size of the brush (diameter) using the keyboard. If
+
is pressed the diameter is increased and if-
is pressed the diameter is decreased. You can use thekeyPressed()
function for that. p5 will call thekeyPressed()
function.