Masking images - Processing for Android.

edited January 2017 in Android Mode

Hello, This is my first program to write a code to mask an image and show portion of background image only on mousepress event. The Java code works just fine on desktop(In Java mode). Whereas in Andriod mode, I don't know what I am missing or where the mistake is, but the background image is displayed and the pg objects paints itself over and over - how do I correct this? Although mousepress events work just fine. Thanks!!

PGraphics pg;
PImage bgimage;
void setup() {
  size(640, 480);
  bgimage = loadImage("background.jpg");
  bgimage.resize(640,480);  

  pg = createGraphics(640, 480);
  pg.beginDraw();
  pg.background(0);
  pg.smooth();
  pg.noStroke();
  pg.fill(255);
  pg.endDraw();
}
void draw()
{ 
  image(bgimage,640,480);

  pg.beginDraw();
  if (mousePressed)
  pg.ellipse(mouseX, mouseY, 100, 100);
  pg.endDraw();

  bgimage.mask(pg);
  image(bgimage,0,0);
}
Tagged:
This discussion has been closed.