Quantcast
Channel: Android Mode - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 941

A program to mask an image - Android.

$
0
0

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 object 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);
    }

Viewing all articles
Browse latest Browse all 941

Trending Articles