Clear Animated GIF from Sketch

Hi,

I'm using this library: https://github.com/01010101/GifAnimation to play animated gif. I wish to clear the sketch before loading a new gif file but are not sure how to achieve that.

Regards.

Tagged:

Answers

  • Answer ✓

    to clear the sketch before loading a new gif file but are not sure how to achieve that.

    I am not sure how yo are loading your sketch? Please ensure ou provide some code with your question. Also consider checking the examples that comes with the library. In the PDE, go to file>>Examples and then go to folder Contributed libraries>>GifAnaimation.

    Kf

    Gif myAnimation,myAnimation2;
    int cplay=0;  //Current gif playing. Either 0 or 1
    
    void setup() {
        size(400,400);
        myAnimation = new Gif(this, "lavalamp.gif");
        myAnimation2 = new Gif(this, "solar.gif");
    
        myAnimation.play();
        cplay=0;
    }
    
    void draw() {
    
      background(0);
    
       if(ctr==0){
         image(myAnimation, 10, 10);
      }
      else{
          image(myAnimation2, 10, 10);
      }
    
    }
    
    void mouseReleased(){
      ctr= (ctr+1)%2; //Either 0 or 1
    
      myAnimation .stop();
      myAnimation2.stop();
    
       if(ctr==0){
        myAnimation.play();
      }
      else{
         myAnimation2.loop();
      }
    }
    
  • Thank you so much!

Sign In or Register to comment.