animated masking

edited May 2016 in How To...

Hi,

I'm trying to use a sound responsive rectangle to either be revealed with a mask or have it reveal an image of a sound meter. I seem to be having trouble getting anything to work the way I imagine. I've tried saving the rect as a PGraphic and masking that. I've tried revealing a transparent png meter but the transparent areas are just showing up as black areas.

It seems like it should be super straightforward, but I'm getting nowhere

Answers

  • You can only mask a PGraphics with a PGraphics if you're using the OPENGL renderer for the PGraphics object, which in turn is only possible if you explicitly call either P2D or P3D as the third argument to size(). (I think this may technically be a bug in Processing since nowadays OPENGL is the default renderer). Here's an example sketch that demonstrates using a PGraphics to mask both a PImage and a PGraphics. It also includes two marked out lines. If you swap those in you'll see the error, which will manifest itself by spitting out the error "mask() is not available with this renderer." and failing to mask the sourcePGraphics: https://gist.github.com/atduskgreg/6835219

  • Thanks... that's got me one step further. Curious if anyone can explain why applying P2D or P3D seems to flip loaded images vertically?

Sign In or Register to comment.