How to add/remove a shape with a key press in Processing?

edited October 2013 in How To...

I want to add/remove an ellipse using a press of a button in Processing. I use void keyPressed() and void keyReleased() for the keys. But how can I use if statements to add/remove an ellipse? Please give me some hints. Thank you.

Answers

  • Moved to How To category, seems fitting given your subject line...

    Have a global variable, a boolean. Set it to true in keyPressed, to false in keyReleased, for example (or make it to toggle in keyPressed).

    Draw the ellipse in draw(), depending on this variable:

    if (mustHide) // The global boolean
    {
      ellipse( ... ); // Your call here
    }
    
Sign In or Register to comment.