Question

I've been searching for answer for about 2 hours now and I haven't found my desired answer. My question is, Is it possible, and how, to draw a circle-shaped texture, so that outside the circle, texture would be transparent, is it even possible?

Thanks in advance! This site has been a great help so far!

Was it helpful?

Solution

The easiest way is to open a program like Photoshop and make an image with an alpha-channel. That means: Start with a completely transparent image and draw a circle on it. Then save it as .png

You can then just load it in your game and render it using a SpriteBatch. It (or better your graphics card) knows how to handle the alphachannel and will keep everything but the circle completely invisible.

This way you do not have to manipulate any pixmaps at runtime and you are not limited to simple shapes like circles.

OTHER TIPS

If the portion of the texture you want to see in the circle is not meant to change during execution, the easiest way is to open Photoshop, make what you want, export it as an image and then load it in a Texture or a Sprite object in your code.

But this can also be done at runtime, via OpenGL using a Stencil test. This is the only solution if the portion displayed in the circle will have to be alterable during execution.

pixmap use this link if u are using other than .png format for your images

Apart form it if you are using png images then just draw the cirlce. Outside the circle will remain transparent.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top