Take a still image from draw

edited March 2018 in How To...

Hi guys, i'm new here (i'm sorry in advance for my bad english). I want take a still image from my canvas while the animation running. I tried with copy() or get(), but these commands just copy every frame of draw(), constantly, while i would like to take a single picture and show it on the same sketch. How can i do it? Thanks in advance



  • You could use the mouse of keyboard to trigger a copy or get like this

    void mouseClicked() {
      // Copy or get when the mouse is clicked
    void keyTyped(){
      if(key == 's' {
        // Copy or get when the 's' key is typed (pressed & released)
  • Demo: Capture image placed in the top right corner every 5 seconds approx. Use the mouse to draw something on the surface.


    final int RAD=25;
    PImage screenShot;
    void setup() {
      size(600, 400);
    void draw() {
      fill(255, 144);
      ellipse(mouseX, mouseY, RAD, RAD);
      //Next resets sketch every 5 secs approx.
      if (frameCount%150==0) {
        background(0);   //Reset/clear current sketch 
      fill(0, 250, 25);
      rect(width*0.78, height*0.08, screenShot.width*1.2, screenShot.height*1.2);
      image(screenShot, width*0.80, height*0.10);
    void captureImage() {
      screenShot=get();  //Captures current screen
      screenShot.resize(int(width*0.18), 0);  //Keep width:height ratio
Sign In or Register to comment.