Reading the source code, this seems built-in behavior:
/** Draws an arc using {@link ShapeType#Line} or {@link ShapeType#Filled}. */
public void arc (float x, float y, float radius, float start, float degrees, int segments) {
if (segments <= 0) throw new IllegalArgumentException("segments must be > 0.");
float colorBits = color.toFloatBits();
float theta = (2 * MathUtils.PI * (degrees / 360.0f)) / segments;
float cos = MathUtils.cos(theta);
float sin = MathUtils.sin(theta);
float cx = radius * MathUtils.cos(start * MathUtils.degreesToRadians);
float cy = radius * MathUtils.sin(start * MathUtils.degreesToRadians);
if (shapeType == ShapeType.Line) {
check(ShapeType.Line, ShapeType.Filled, segments * 2 + 2);
renderer.color(colorBits);
renderer.vertex(x, y, 0); <--- CENTER
renderer.color(colorBits);
renderer.vertex(x + cx, y + cy, 0); <--- LINE TO START POINT
for (int i = 0; i < segments; i++) {
renderer.color(colorBits);
renderer.vertex(x + cx, y + cy, 0);
float temp = cx;
cx = cos * cx - sin * cy;
cy = sin * temp + cos * cy;
renderer.color(colorBits);
renderer.vertex(x + cx, y + cy, 0);
}
renderer.color(colorBits);
renderer.vertex(x + cx, y + cy, 0); <-- LINE TO END POINT
...
Easiest is probably to copy the entire function and at least throw out two of the lines I marked: CENTER
and LINE TO END POINT
, along with the accompanying renderer.color(..
line above each.
(You can also delete the LINE TO START POINT
–?it appears to set the starting point for the curve, but that's actually also done inside the loop, so it's redundant.)
The function has a second part for a filled "arc" (I agree, it should have properly been named "pie" or "wedge"), but you don't need that here because it would do exactly the same.
If you get it to work, you could propose it to libgdx's maintainers, for example on libgdx's Contributions Forum.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…