Oct 07
Drawing with a clear button in Processing
Fundamentals of Physical Computing
Lab Five: Processing, part 8: Create a clear button
- Decide an area on the sketch’s canvas outside of the drawable area, where when the mouse is pressed in it, everything that has been drawn so far is erased.
- In comments in your code, write the extents of this area. (Just like you did in the previous program.)
- Draw a rectangle that visually shows where the clear button is. You’ll do this in your program where you initially drew the drawable area. Write a comment describing the clear button in the code.
- Write a conditional (or nested conditionals) in your program that checks for the mouse being within the button area, and when the mouse is pressed. (This is exacly the SAME structure as your drawable area, except the extents will be different). Put this conditional after the one you previously wrote.
- In the body of this conditional (between the curly braces), write code clears everything that has been drawn. To do this, just simply re-draw the drawable area that you did at the beginning of the program. This should clear what has been drawn.