Mask on top of Gif

Hello hello! Trying to place a mask over a Gif "generator" which refreshes every 5 seconds. Mask appears at first but the problem I'm running into is that the mask does not draw over subsequent loops.

import gifAnimation.*;

Gif loopingGif;
PFont font;
int rand;
int interval = 3000; //timer's interval
int lastRecordedTime = -12200;
PImage masker;

//int difference=12000;


void setup() {
  size(displayWidth, displayHeight);
  }
  smooth();
  //noFill();
  font = createFont("Verdana",12);
  textFont(font);
  masker= loadImage("mask2.png");

}

void draw() {
 if(millis()-lastRecordedTime>interval) {
  rand = int(random(1,10)); //HERE YOU CHOOSE BETWEEN 10 DIFFERENT IMAGES
   String fn= ((rand) + ".gif"); //CALL YOUR FUNCTION 'takerandomimage'
   loopingGif = new Gif(this, fn);
   loopingGif.loop();
   lastRecordedTime= millis();
}
 else {
loopingGif.mask(masker);
image(loopingGif, displayWidth/3, displayHeight/3);
}
}

Any ideas?

Answers

  • Answer ✓

    You can try something like that

    if(frameCount%5==0) loopingGif.mask( ...

    it's easier and it loops.

Sign In or Register to comment.