在ipad中实现徒手画点缺失问题
我正在制作一个徒手 ipad 绘图应用程序,例如带有某种画笔的“画笔”。 我的问题是 touchmove 事件错过了快速移动的一些点。
所以我想获取先前位置和当前位置之间的所有这些中间点来绘制画笔图案。
我实施了布雷森汉姆线算法来获得所有这些点,但它降低了性能,您能指导我什么是最好的方法吗?
谢谢 。
i am making a free hand ipad drawing app like "brushes" with some kind of brushes.
my problem is that touchmove event misses some points on fast moving.
so i want to get all these intermediate points between previous location and current location to plot brush pattern.
i implemented bresenham line algorthm to get all these points but it slows the performance can you please guide me what is the best way to do this.
Thanks .
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您像问号所暗示的那样使用 Core Graphics,为什么不直接绘制从每个点到下一个点的 CG 路径呢?
此外,Bresenham 实际上是用于像素级光栅化,这几乎肯定不是您真正想要做的。您的坐标几乎肯定是浮点型(如果您在 Core Graphics 中则为浮点型)并且可以是非整数。 (FWIW,我很惊讶 Bresenham 在这里很慢。这不是一个计算密集型技术,而且由于我们已经过了 286 天了,我无法想象这是你的瓶颈。)
If you're using Core Graphics like the question tag implies, why not just draw a CG path from each point to the next one?
Also, Bresenham is really for pixel-level rasterization, which is almost certainly not what you're actually trying to do. Your coordinates are almost certainly floating point (they are if you're in Core Graphics) and can be non-integral. (And FWIW I'm surprised that Bresenham is slow here. It's not a computationally intensive technique, and since we're long past the 286 days, I can't imagine that's your bottleneck.)