How would you draw a CapsuleShape2D?

Godot Version

4.5

Question

Hello everyone!

I am trying to draw various Shape2D with _draw().
Drawing circles and rectangles is easy with dedicated draw_circle() and draw_rect()

But how would you draw a CapsuleShape2D?

Thank you very much in advance for any help :slight_smile:

Combine circles and rects if its filled, and arcs and lines if its outlined.

1 Like

Such a simple solution, thank you so much!

I am just worried because my fill color has transparency, I think the overlap will show

If you only draw a single shape per canvas item you can set the transparency for the whole thing via canvas item’s modulate. Otherwise you can draw the whole capsule as a polygon, or a composition of a rect and two half-circle polygons.

1 Like

Thank you for the details, it helps!