为什么绘制路径不起作用?
我有这个绘制路径的代码,但没有显示任何内容,我不明白为什么。
//i move the path's starting point somewhere up here to a point.
//get center x and y are the centers of a picture. it works when i
//do drawline and store the different starting points
//but i want it to look continuous not like a lot of different
//lines
path.lineTo(a.getCenterX(), a.getCenterY());
path.moveTo(a.getCenterX(), a.getCenterY());
p.setStrokeWidth(50);
p.setColor(Color.BLACK);
canvas.drawPath(path,p);
提前致谢
I have this code for drawpath and nothing shows up and I cant figure out why.
//i move the path's starting point somewhere up here to a point.
//get center x and y are the centers of a picture. it works when i
//do drawline and store the different starting points
//but i want it to look continuous not like a lot of different
//lines
path.lineTo(a.getCenterX(), a.getCenterY());
path.moveTo(a.getCenterX(), a.getCenterY());
p.setStrokeWidth(50);
p.setColor(Color.BLACK);
canvas.drawPath(path,p);
thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
新的 Paint 实例仅填充路径。
要描边路径,请设置绘画样式:
如果您要绘画的背景是黑色,请更改颜色,以便您可以看到绘画:
可选:
A new Paint instance only fills paths.
To stroke paths, set the Paint style:
If the background you're painting on is black, change the color, so you can see the paint:
Optional:
我必须将其添加到绘画中才能使其发挥作用。不知道为什么。
i had to add this to paint in order to make it work. dunno why.
我认为解决您的问题的最佳方法是按如下方式更改代码:
您可能必须使用它,但这应该基本上与线条重叠,因此看起来它们是连续的。
您可能需要在绘制方向上放置一个 switch 语句,但这应该是相当简单的。
我希望这有帮助!
I think the best way to solve your problem is by changing the code as follows:
You may have to play with this, but this should basically overlap the lines so it looks like they are continuous.
You will likely have to put a switch statement in for which direction you are drawing in, but that should be fairly trivial.
I hope this helps!