aseboagri.blogg.se

Simple drawing outlines
Simple drawing outlines







simple drawing outlines

Outer_r, color.r, color.g, color.b, opacity) Sdlgfx.filledCircleRGBA(self.sdl_renderer, x, y, # If the penwidth is larger than 1, things become a bit more complex. Sdlgfx.circleRGBA(self.sdl_renderer, x, y, r, color.r, color.g, color.b, opacity) Sdlgfx.aacircleRGBA(self.sdl_renderer, x, y, r, color.r, color.g, color.b, opacity) # If penwidth is 1, simple use sdl2gfx own functions Sdlgfx.filledCircleRGBA(self.sdl_renderer, x, y, r, color.r, color.g, color.b, opacity) # if the circle needs to be filled, it's easy # Check for invalid penwidth values, and make sure the value is an int # Get background color set for this texture # convert possible opacity values to the right scale # convert color parameter to sdl2 understandable values # Make sure all spatial parameters are ints

simple drawing outlines

Here's an example of a function using this approach: draw_circle(self, x, y, r, color, opacity=1.0, fill=True, aa=False, penwidth=1): However, this obscures everything behind the circle (in this case the white line). To explain things a bit better visually: what I'm trying to achieve is:Ī circle (annulus) larger than 1px wide of which the interior is transparent, such that items drawn behind the circle will be visible in the interior.Ī trick that I have used in the past is to just draw 2 filled circles, where a second smaller circle has the same color as the background. I have done something like this before with pygame surfaces using transparent color keys ( inspired by this method), and I know surfaces are also available in SDL2, but the caveat is that I'm trying to stick to the much faster textures, which do not provide the color key mechanism. It seems downright impossible to draw circles with thicker outlines. Of course, this is very simple to achieve with the sdl2gfx function circleRGBA(), but it only allows you to draw outlines with a line width of 1px. I want to draw a circle outline with sdl2 in python.

simple drawing outlines

I am trying to achieve something that seems conceptually very simple, but I just can't make it happen. I'd like to use Textures instead of Surfaces, as far as this is possible. Basically I need to find a way to erase the pixels of the interior of a filled circle (or draw them over with/set them back to transparent pixels). TL DR: Using (py)sdl2, I am trying to draw a circle outline of which the interior is transparent and thus shows objects drawn behind it.









Simple drawing outlines