We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I have this image:
I want to whiten out everything around the thicker stroked large circle.
I would just use a background image with a cutout but the size of this structure changes so that won't work.
I would just make a few thick stroked white circles with no fill incrementing larger w/h than the thick circle there, but as the circle size changes, the stroke weights and spacings have to be carefully adjusted to match.
Is there a more solid (pun intended) for this?
Answers
You can draw in a PGraphics, dynamically draw a mask in another one and display the first masked by the second...
Ok, but that seems to be for two images, correct? This is generated with code. Is it still possible? I tried making my own pImage, drawing a white background with a black (for testing) ellipse in the center like above but with 0 opacity. I display it after everything else hoping that the lack of opacity let's the other stuff go through, but it doesn't. I get the white background and even a white ellipse (because 0 opacity) but nothing gets through...
Either it isn't possible or I misunderstand something.
I globally define
var aMask;
(using p5js for this but it's the same / similar).In setup I do:
then after drawing the graphics in draw(), I do
image(aMask, 0, 0);
but as I said, this doesn't work...
just paint white circle with radius 1000
for loop
radius getting smaller down to 500
painting that many circles at 60 fps kind of kills the frame rate, it seems. I don't think it's the best solution.
What I had in mind is the following. But There are other ways to do that. Also I'm not using p5.js. Don't know id it will work there.
on line here
http://sketchpad.cc/Kf2CzdZoDZ
the code
That works well. Only problem is I believe mask in P5JS is only a method for an image object not a graphics (renderer) object. At least, this is my suspicion. I'll take the convo there. Thanks for your answer.
Interesting. Is this something they know about and have thought about? I'm am having similar problems here: forum.processing.org/two/discussion/12015/cam-get#latest for likely similar reasons. These problems don't exist in the Java version.
P5js is still pretty new. Hopefully it's something they make better soon!
Just by going there, I've already spotted another issue related to the fact that a p5.Renderer isn't a p5.Image and it's wrapped up by a p5.Graphics: :P
https://GitHub.com/processing/p5.js/issues/854
Apparently function save() doesn't accept a p5.Renderer parameter, even though it says so!
Or at least, not when a p5.Renderer is wrapped up inside a p5.Graphics object. Who knows? (:|
P.S.: I've spotted your request there too: https://GitHub.com/processing/p5.js/issues/855 B-)
Another approach without PGraphics... Still in Java mode.
http://sketchpad.cc/65cAwJgUKr