Search code examples
libgdxdrawing

Drawing shapes by pixel in libgdx


I'm trying to draw shapes in libgdx that change constantly so I don't think using sprites will work, and I was wondering if it is possible to draw a shape using a function that is called for each pixel to determine if it should be drawn.

What I need to draw is part of a washer (an area bound by two concentric circles and two radiuses), with the circles and radiuses changing constantly.

What I want to know is wether here is a way to draw complex shapes that are determined by a function (the shape would consist of those (x,y) for wich theFunction(x,y)=true) instead of an image


Solution

  • Everything is possible. The best solution really depends on the details of what you want to create. Perhaps you can show an example of what you mean?

    Without seeing an example, it looks you might want to start with ShapeRenderer. See the javadocs for detailed information on how to use it. That should get you started and if you find it to be insufficient in some way then you at least you have a more specific question.

    Btw, using a Pixmap as suggested by @Ludevik is also possible, but since you want it to change constantly that would imply uploading the entire image each frame which is not very performant.