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:我能以某种方式改变线条的宽度吗?
基础教程推荐
- 在螺旋中写一个字符串 2022-01-01
- 如何使用 Stream 在集合中拆分奇数和偶数以及两者的总和 2022-01-01
- 如何对 HashSet 进行排序? 2022-01-01
- 首次使用 Hadoop,MapReduce Job 不运行 Reduce Phase 2022-01-01
- 由于对所需库 rt.jar 的限制,对类的访问限制? 2022-01-01
- Spring Boot Freemarker从2.2.0升级失败 2022-01-01
- Java 中保存最后 N 个元素的大小受限队列 2022-01-01
- 如何使用 Eclipse 检查调试符号状态? 2022-01-01
- 如何在不安装整个 WTP 包的情况下将 Tomcat 8 添加到 Eclipse Kepler 2022-01-01
- 如何强制对超级方法进行多态调用? 2022-01-01