It looks like you're new here. If you want to get involved, click one of these buttons!
Hello experts,
I am trying to render the camera image sprite on a circle instead of a rectangle. The way I have imagined this would work is via an overlay. The problem I have is the circle is not transparent even if I set blend mode to transparent.
Furthermore, Is this the most efficient way to crop the camera image into a circle? Any help appreciated.
imageOverlay = image(100,100)
setContext( imageOverlay )
fill(0, 0, 0, 255)
rect(0, 0, 100, 100)
blendMode(ZERO, ZERO)
ellipseMode(CORNER)
local alpha = 0
fill(0, 0, 0, 0)
ellipse(0, 0, 100, 100)
blendMode(NORMAL)
setContext()
Then in the on draw function.
sprite( CAMERA, self.x, self.y, 100, 100 )
sprite(imageOverlay, self.x, self.y)
Comments
Here's a way to do it using CircleMask class
JakAttak,
Thanks works like a charm
I modified @JakAttak’s code to make circular-mesh-creation a simple function, not a class, so it can more easily be cut-and-pasted into other projects.
I needed to do that kind of thing with it, so I figure other people might want to also.
And because I just can’t stop putting icons on things, I’m attaching a zip that includes an icon.