简体   繁体   中英

How can I fill a circle in libgdx?

using the ShapeRenderer class, I can only fill rectangles.

  • So how can I fill a circle?
  • and if possible, fill a sector (portion of a circle)?

As in the example of the shaperender

 shapeRenderer.begin(ShapeType.Filled);
 shapeRenderer.setColor(0, 1, 0, 1);
 shapeRenderer.rect(x, y, width, height); // fills a rect
 shapeRenderer.circle(x, y, radius);//<--- fills a circle
 shapeRenderer.end();

should fill the circle. How to get a portion of a cicle i have no clue. Maybe create a mesh and fill it or such like that. Take a look at the shaperender there are differnet methods to fill parts. Just check if some of them fit.

For your second question, there is a method that fills only a portion of a circle

shapeRenderer.begin(ShapeType.Filled);
shapeRenderer.setColor(0, 1, 0, 1);
shapeRenderer.arc(x, y, radius, start, degrees, segments); // Fills a portion of a circle
shapeRenderer.end();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM