amidoinitrite homework

Offscreen drawing

Making my way through the Offscreen drawing recipe from the Processing 2 Creative programming cookbook source code on GitHub. In this recipe I learned how to:

  • declare a PGraphics object and then initialise it with the createGraphics function inside the setup function.
  • use the createGraphics function to create a new transparent image to be drawn on and the beginDraw and endDraw functions to start and stop drawing on the image. For this Sketch, strokes and lines are drawn on the PGraphics object. To do this, they needed to be prefixed with a variable (pg).

The display window is cleared every time the mouse is pressed. The if test inside the mousePressed function specifies there’s a 50 percent chance the new background will be black or white.


Leave a Reply

Your email address will not be published. Required fields are marked *