我想画一条线,然后生成一个纹理(使用 libgdx).我发现使用 pixmap 从圆形、矩形和线条创建纹理很简单.但是我没有找到如何设置绘制形状的线宽.是否可以设置像素图的线宽?
I want to draw a line and then generate a texture (with libgdx). I found out that creating a texture from circles, rectangles and lines is simple with pixmap. But I didn't find out how to set the linewidth of the drawn shape. Is there any possibility to set the linewidth for pixmap?
这是我目前得到的代码:(我试着画了两个实心圆圈并用一条线连接它们)
Here is the code I got so far: (I tried to draw two filled circles and to connect them with a line)
Pixmap pixmap = new Pixmap( 16, 16, Format.RGBA8888 );
pixmap.setColor(Color.BLUE);
pixmap.fillCircle(x1, y1, 10);
pixmap.fillCircle(x2, y2, 10);
pixmap.drawLine(x2, y2, x1, y1); // this line is very thin
Texture pixmaptex = new Texture( pixmap );
pixmap.dispose();
OpenGL 实现不可靠地支持线宽.要绘制粗"线,请绘制一个矩形.
Linewidth isn't reliably supported by OpenGL implementations. To draw "fat" lines, draw a rectangle.
请参阅 Libgdx gl10.glLineWidth()
这篇关于libgdx- pixmap:我能以某种方式改变线条的宽度吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!