libgdx- pixmap: can I somehow change the width of the line?(libgdx- pixmap:我能以某种方式改变线条的宽度吗?)
问题描述
我想画一条线,然后生成一个纹理(使用 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:我能以某种方式改变线条的宽度吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:libgdx- pixmap:我能以某种方式改变线条的宽度吗?


- GC_FOR_ALLOC 是否更“严重"?在调查内存使用情况时? 2022-01-01
- 如何指定 CORS 的响应标头? 2022-01-01
- java.lang.IllegalStateException:Bean 名称“类别"的 BindingResult 和普通目标对象都不能用作请求属性 2022-01-01
- 获取数字的最后一位 2022-01-01
- 将 Java Swing 桌面应用程序国际化的最佳实践是什么? 2022-01-01
- 在 Java 中,如何将 String 转换为 char 或将 char 转换 2022-01-01
- Eclipse 的最佳 XML 编辑器 2022-01-01
- 转换 ldap 日期 2022-01-01
- 如何使 JFrame 背景和 JPanel 透明且仅显示图像 2022-01-01
- 未找到/usr/local/lib 中的库 2022-01-01