ShapeDrawer - draws shapes using a Batch

Any community contributions to libgdx go here! Some may get included in the core API when permission is granted.

ShapeDrawer - draws shapes using a Batch

Postby earlygrey » Thu Oct 24, 2019 12:51 pm

ShapeDrawer draws simple shapes like ShapeRenderer does, but uses a Batch to perform the drawing. This means it can be used in between Batch#begin() and Batch#end() without needing to flush the Batch.

Comes with overloaded methods to draw lines, paths, ellipses, regular polygons and rectangles.


Here's a link to the github, you can read more about it in the wiki:

To create a ShapeDrawer instance you just need a Batch and a TextureRegion. Typically this is a single white pixel so that you can easily colour it, and is best packed into an atlas with your other textures.

To instantiate a ShapeDrawer, use:
Code: Select all
ShapeDrawer drawer = new ShapeDrawer(batch, region);

And to use it, simply call its drawing methods in between Batch#begin() and Batch#end(). Something like this:
Code: Select all
drawer.line(0, 0, 100, 100);

Uses MIT license. Any issues/questions let me know!
Posts: 1
Joined: Tue Oct 22, 2019 12:30 pm

Return to Libgdx Contributions

Who is online

Users browsing this forum: No registered users and 1 guest