Skip to content

A library for libgdx that draws simple shapes using a batch.

License

Notifications You must be signed in to change notification settings

suthcark/shapedrawer

 
 

Repository files navigation

Shape Drawer


A library for libgdx, an open-source game development application framework written in java.

Draws simple shapes like libgdx's 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.

Just needs to be provided with a Batch (SpriteBatch or PolygonSpriteBatch will work) and a TextureRegion.


Including in Project

To use this in your gradle project, add the following to your root build.gradle file:

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

And in your core project add the dependency:

dependencies {
        implementation 'space.earlygrey:shapedrawer:1.1.0'
}

For HTML5/GWT support, add the dependency to the html project:

project(":html") {
    apply plugin: "gwt"
    apply plugin: "war"


    dependencies {
        ...
        implementation 'space.earlygrey:shapedrawer:1.1.0:sources'
    }
}

And add the following line to the GdxDefinition.gwt.xml file in the HTML project:

<inherits name="space.earlygrey.shapedrawer"/>

See the jitpack website for more info.

Usage

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:

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:

batch.begin();
drawer.line(0, 0, 100, 100);
batch.end();

That's it!


Check the wiki for more info, including:


Test application uses the Commodore 64 UI Skin created by Raymond "Raeleus" Buckley under the CC BY license. Check out the others!

About

A library for libgdx that draws simple shapes using a batch.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%