<bdo id='af4eR'></bdo><ul id='af4eR'></ul>

      <small id='af4eR'></small><noframes id='af4eR'>

      <i id='af4eR'><tr id='af4eR'><dt id='af4eR'><q id='af4eR'><span id='af4eR'><b id='af4eR'><form id='af4eR'><ins id='af4eR'></ins><ul id='af4eR'></ul><sub id='af4eR'></sub></form><legend id='af4eR'></legend><bdo id='af4eR'><pre id='af4eR'><center id='af4eR'></center></pre></bdo></b><th id='af4eR'></th></span></q></dt></tr></i><div id='af4eR'><tfoot id='af4eR'></tfoot><dl id='af4eR'><fieldset id='af4eR'></fieldset></dl></div>
    1. <legend id='af4eR'><style id='af4eR'><dir id='af4eR'><q id='af4eR'></q></dir></style></legend>

    2. <tfoot id='af4eR'></tfoot>

      libgdx 绘制圆弧曲线

      时间:2023-05-19

        <small id='r16Dv'></small><noframes id='r16Dv'>

        <i id='r16Dv'><tr id='r16Dv'><dt id='r16Dv'><q id='r16Dv'><span id='r16Dv'><b id='r16Dv'><form id='r16Dv'><ins id='r16Dv'></ins><ul id='r16Dv'></ul><sub id='r16Dv'></sub></form><legend id='r16Dv'></legend><bdo id='r16Dv'><pre id='r16Dv'><center id='r16Dv'></center></pre></bdo></b><th id='r16Dv'></th></span></q></dt></tr></i><div id='r16Dv'><tfoot id='r16Dv'></tfoot><dl id='r16Dv'><fieldset id='r16Dv'></fieldset></dl></div>

          <tfoot id='r16Dv'></tfoot>
              <tbody id='r16Dv'></tbody>
            • <bdo id='r16Dv'></bdo><ul id='r16Dv'></ul>
                <legend id='r16Dv'><style id='r16Dv'><dir id='r16Dv'><q id='r16Dv'></q></dir></style></legend>
                本文介绍了libgdx 绘制圆弧曲线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                libgdx 的 arc 函数不是画圆弧而是画一个饼段(即有 2 条线连接到圆弧的原点)

                The arc function of libgdx instead of drawing a arc draws a pie segment (ie. has 2 lines connecting to the arc's origin)

                shapeRenderer.begin(ShapeType.Line);
                shapeRenderer.arc(x, y, radius, 30, 120);
                shapeRenderer.end();
                

                有没有办法解决这个问题,让libgdx可以画出类似于html5 canvas arc函数的圆弧曲线?

                Is there a solution to this problem so that libgdx can draw an arc curve similar to the html5 canvas arc function?

                推荐答案

                阅读源码,这似乎是内置行为:

                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
                ...

                最简单的方法可能是复制整个函数并至少去掉我标记的两行:CENTERLINE TO END POINT,以及每个上面的随附 renderer.color(.. 行.

                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.

                (您也可以删除 LINE TO START POINT - 它似乎设置曲线的起点,但实际上也是在循环内完成,所以它是多余的.)

                (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.

                如果你让它工作,你可以将它推荐给 libgdx 的维护者,例如在 libgdx 的贡献论坛.

                If you get it to work, you could propose it to libgdx's maintainers, for example on libgdx's Contributions Forum.

                这篇关于libgdx 绘制圆弧曲线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:当我在 Android 上运行 Libgdx 项目时,代码的更改没 下一篇:BodyEditorLoader - noSuchMethod

                相关文章

                最新文章

                <i id='uem7e'><tr id='uem7e'><dt id='uem7e'><q id='uem7e'><span id='uem7e'><b id='uem7e'><form id='uem7e'><ins id='uem7e'></ins><ul id='uem7e'></ul><sub id='uem7e'></sub></form><legend id='uem7e'></legend><bdo id='uem7e'><pre id='uem7e'><center id='uem7e'></center></pre></bdo></b><th id='uem7e'></th></span></q></dt></tr></i><div id='uem7e'><tfoot id='uem7e'></tfoot><dl id='uem7e'><fieldset id='uem7e'></fieldset></dl></div>
                • <bdo id='uem7e'></bdo><ul id='uem7e'></ul>
              • <tfoot id='uem7e'></tfoot>

                1. <legend id='uem7e'><style id='uem7e'><dir id='uem7e'><q id='uem7e'></q></dir></style></legend>
                  1. <small id='uem7e'></small><noframes id='uem7e'>