在Libgdx中绘制一个平滑且连续的弧

时间:2017-10-24 04:03:38

标签: android libgdx

我尝试使用以下代码绘制连续弧来制作饼图。如果给出了段,则边缘不平滑。如果给出了段,则Arcs / Pie之间存在间隙。检查蓝色和灰色之间的小区域。如何获得平滑的边缘和连续的弧?

    game.shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
    game.shapeRenderer.arc(x, y, radius,0,30);
    game.shapeRenderer.setColor(Color.GRAY);
    game.shapeRenderer.arc(x, y, radius,30,45);
    game.shapeRenderer.setColor(Color.BROWN);
    game.shapeRenderer.arc(x, y, radius,75,65);
    game.shapeRenderer.setColor(Color.RED);
    game.shapeRenderer.arc(x, y, radius,140,80);
    game.shapeRenderer.setColor(Color.BLUE);
    game.shapeRenderer.arc(x, y, radius,220,140);

    y=300;

    game.shapeRenderer.arc(x, y, radius,0,30,180);
    game.shapeRenderer.setColor(Color.GRAY);
    game.shapeRenderer.arc(x, y, radius,30,45,180);
    game.shapeRenderer.setColor(Color.BROWN);
    game.shapeRenderer.arc(x, y, radius,75,65,180);
    game.shapeRenderer.setColor(Color.RED);
    game.shapeRenderer.arc(x, y, radius,140,80,180);
    game.shapeRenderer.setColor(Color.BLUE);
    game.shapeRenderer.arc(x, y, radius,220,140,180);
    game.shapeRenderer.end();

enter image description here

1 个答案:

答案 0 :(得分:0)

将samples配置为高;

final LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
cfg.samples = 4;