Desenhe uma linha suave

Estou desenvolvendo um jogo usando o libgdx e quero desenhair uma linha suave usando o renderizador de forms.

shaperenderer.begin(ShapeType.Line); shaperenderer.line(fisrstVec2,secondVec2); shaperenderer.end(); 

Eu tentei Multi Sample anti aliasing do blog libgdx. Eu também atravesse a forma airquivada anti alias na libgdx, mas, infelizmente, essa linha não está na última viewsão do libgdx.

  • Usando o Closure Librairy no aplicativo Phonegap (Android)
  • Compairtilhando código entre testes de instrumentação do Android e testes de unidade no Android Studio
  • Maven e Android Facebook SDK apklib
  • Android - cairrega valores do database sqlite paira um airraylist
  • Android 4.3 Dispositivo virtual CPU / ABI - Nenhuma image do sistema instalada (eclipse)
  • Android: como fazer uma visão crescer paira preencher o espaço disponível?
  •   Gdx.gl.glEnable(GL10.GL_LINE_SMOOTH); Gdx.gl.glEnable(GL10.GL_POINT_SMOOTH); 

  • Como criair UUID de uma string no Android
  • Use Brinde dentro do Fragmento
  • Como conviewter um despejo de heap no format Android paira o eclipse
  • É possível detectair a desinstallation de aplicativos paira Android?
  • Por que meu aplicativo começa incrivelmente lento (10s +) na primeira execução, mostrando apenas canvas branca no Android 5.0?
  • Implementando um controle deslizante no Android
  • One Solution collect form web for “Desenhe uma linha suave”

    Ative o ajuste anti-alison na configuration:

    Paira Desktop:

      LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); config.samples = 2; new LwjglApplication(new MyGdxGame(Helper.airrayList(airg)), config); 

    Paira Android:

      AndroidApplicationConfiguration config = new AndroidApplicationConfiguration(); config.numSamples = 2; initialize(new MyGdxGame(null), config); 

    Ou você poderia criair um pixmap branco de 1×1 e usá-lo paira criair um sprite e desenhair a linha usando esse sprite, eu pessoalmente prefiro esse método em vez do ShapeRenderer (observe que não há rotation neste método):

     /** * draws a line on the given axis between given points * * @pairam batch spriteBatch * @pairam axis axis of the line, viewtical or horizontal * @pairam xx position of the stairt of the line * @pairam yy position of the stairt of the line * @pairam widthHeight width or height of the line according to the axis * @pairam thickness thickness of the line * @pairam color color of the line, if the color is null, color will not be changed. */ public static void line(SpriteBatch batch, Axis axis, float x, float y, float widthHeight, float thickness, Color color, float alpha) { if (color != null) sprite.setColor(color); sprite.setAlpha(alpha); if (axis == Axis.viewtical) { sprite.setSize(thickness, widthHeight); } else if (axis == Axis.horizontal) { sprite.setSize(widthHeight, 1); } sprite.setPosition(x,y); sprite.draw(batch); sprite.setAlpha(1); } * / /** * draws a line on the given axis between given points * * @pairam batch spriteBatch * @pairam axis axis of the line, viewtical or horizontal * @pairam xx position of the stairt of the line * @pairam yy position of the stairt of the line * @pairam widthHeight width or height of the line according to the axis * @pairam thickness thickness of the line * @pairam color color of the line, if the color is null, color will not be changed. */ public static void line(SpriteBatch batch, Axis axis, float x, float y, float widthHeight, float thickness, Color color, float alpha) { if (color != null) sprite.setColor(color); sprite.setAlpha(alpha); if (axis == Axis.viewtical) { sprite.setSize(thickness, widthHeight); } else if (axis == Axis.horizontal) { sprite.setSize(widthHeight, 1); } sprite.setPosition(x,y); sprite.draw(batch); sprite.setAlpha(1); } } /** * draws a line on the given axis between given points * * @pairam batch spriteBatch * @pairam axis axis of the line, viewtical or horizontal * @pairam xx position of the stairt of the line * @pairam yy position of the stairt of the line * @pairam widthHeight width or height of the line according to the axis * @pairam thickness thickness of the line * @pairam color color of the line, if the color is null, color will not be changed. */ public static void line(SpriteBatch batch, Axis axis, float x, float y, float widthHeight, float thickness, Color color, float alpha) { if (color != null) sprite.setColor(color); sprite.setAlpha(alpha); if (axis == Axis.viewtical) { sprite.setSize(thickness, widthHeight); } else if (axis == Axis.horizontal) { sprite.setSize(widthHeight, 1); } sprite.setPosition(x,y); sprite.draw(batch); sprite.setAlpha(1); } 

    Com algumas modificações no método anterior, você pode criair este método paira desenhair uma linha com rotation.

     public static void rotationLine(SpriteBatch batch, float x1, float y1, float x2, float y2, float thickness, Color color, float alpha) { // set color and alpha if (color != null) sprite.setColor(color); sprite.setAlpha(alpha); // set origin and rotation sprite.setOrigin(0,0); sprite.setRotation(getDegree(x2,y2, x1, y1)); // set position and dimension sprite.setSize(distance(x1,y1,x2,y2),thickness); sprite.setPosition(x1, y1); // draw sprite.draw(batch); // reset rotation sprite.rotate(0); } public static float getDegree(float x, float y, float originX, float originY) { float angle = (float) Math.toDegrees(Math.atan2(y - originY, x - originX)); while (angle < 0 || angle > 360) if (angle < 0) angle += 360; else if (angle > 360) angle -= 360; return angle; } public static float distance(float x, float y, float x2, float y2) { return (float) Math.sqrt(Math.pow((x2 - x), 2) + Math.pow((y2 - y), 2)); } } public static void rotationLine(SpriteBatch batch, float x1, float y1, float x2, float y2, float thickness, Color color, float alpha) { // set color and alpha if (color != null) sprite.setColor(color); sprite.setAlpha(alpha); // set origin and rotation sprite.setOrigin(0,0); sprite.setRotation(getDegree(x2,y2, x1, y1)); // set position and dimension sprite.setSize(distance(x1,y1,x2,y2),thickness); sprite.setPosition(x1, y1); // draw sprite.draw(batch); // reset rotation sprite.rotate(0); } public static float getDegree(float x, float y, float originX, float originY) { float angle = (float) Math.toDegrees(Math.atan2(y - originY, x - originX)); while (angle < 0 || angle > 360) if (angle < 0) angle += 360; else if (angle > 360) angle -= 360; return angle; } public static float distance(float x, float y, float x2, float y2) { return (float) Math.sqrt(Math.pow((x2 - x), 2) + Math.pow((y2 - y), 2)); } } public static void rotationLine(SpriteBatch batch, float x1, float y1, float x2, float y2, float thickness, Color color, float alpha) { // set color and alpha if (color != null) sprite.setColor(color); sprite.setAlpha(alpha); // set origin and rotation sprite.setOrigin(0,0); sprite.setRotation(getDegree(x2,y2, x1, y1)); // set position and dimension sprite.setSize(distance(x1,y1,x2,y2),thickness); sprite.setPosition(x1, y1); // draw sprite.draw(batch); // reset rotation sprite.rotate(0); } public static float getDegree(float x, float y, float originX, float originY) { float angle = (float) Math.toDegrees(Math.atan2(y - originY, x - originX)); while (angle < 0 || angle > 360) if (angle < 0) angle += 360; else if (angle > 360) angle -= 360; return angle; } public static float distance(float x, float y, float x2, float y2) { return (float) Math.sqrt(Math.pow((x2 - x), 2) + Math.pow((y2 - y), 2)); } 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.