Alpha chan from PGraphics
in
Programming Questions
•
3 years ago
I've been trying to create an alpha channel from a PGraphics as follows:
Doing this:
Saving the graphics out to a file and loading it works just as you'd hope:
Seems like a useful technique, creating an offscreen buffer with a PGraphics that serves as an alpha channel for a PImage. I"m sure someone has done it before, but a brief search hasn't turned up the answer.
thanks,
-- Paul
- PGraphics pg = createGraphics(640, 950, P2D);
- pg.beginDraw();
- myRegions[i].draw(this); // draw this shape
- pg.endDraw();
Doing this:
- PImage img = loadImage("raspberries.jpg");
- img.mask(pg);
- image(img,0,0);
Saving the graphics out to a file and loading it works just as you'd hope:
- img.mask(loadImage("mask.png"));
Seems like a useful technique, creating an offscreen buffer with a PGraphics that serves as an alpha channel for a PImage. I"m sure someone has done it before, but a brief search hasn't turned up the answer.
thanks,
-- Paul
1