Code Monkey home page Code Monkey logo

shapedrawer's Introduction

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 and a TextureRegion. However, note that if you want to draw filled shapes, it is more efficient to use a batch that implements PolygonBatch (eg a PolygonSpriteBatch) instead of a Batch that does not (eg a SpriteBatch).

Gif didn't load - see wiki for images!


Including in Project

To use this in your gradle project, add the version number and jitpack repository information to your root build.gradle file:

allprojects {
    ext {
    	...
        shapedrawerVersion = '2.4.0'
    }
    repositories {
	...
	maven { url 'https://jitpack.io' }
    }
}

And in your core project add the dependency:

dependencies {
    implementation "space.earlygrey:shapedrawer:$shapedrawerVersion"
}

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

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


    dependencies {
        ...
        implementation "space.earlygrey:shapedrawer:$shapedrawerVersion: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.

Alternatively, if you're using gdx-liftoff to create your project you can find shape drawer under the "third-party" tab.

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!

shapedrawer's People

Contributors

earlygrey avatar raeleus avatar dgzt avatar payne911 avatar tcreutzenberg avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.