Creating A Toolbar & Canvas Sketch

yes, i try a minimalistic toggle button,
the idea is just to show the use of the

boolean overRect(int x, int y, int w, int h) {
  • -a- for the detection mouse over drawing area ( program flow inside draw() )
  • -b- for the use inside mousePressed() as button click

i not want to rewrite OP’s program, just show how easy it gets when he use that little boolean function.

but also a major point is to show the use of global vars
what define the x,y,w,h of the drawing and button areas
( to be used in the drawing function and the mouse “overRect” )
much better as hardcoded positions inside the code

2 Likes