在iPhone上用手指触摸画出平滑的线条(Draw a smooth line with finger touch on iPhone)

编程入门 行业动态 更新时间:2024-10-26 18:17:24
在iPhone上用手指触摸画出平滑的线条(Draw a smooth line with finger touch on iPhone)

如何在iPhone上用手指滑动/触摸动作绘制平滑线条? 我有以下代码,但它不光滑。 例如,当我尝试做一个循环时,它会让角落/转弯。 我想我必须使用OpenGL。 有任何想法吗? 示例代码? 教程?

谢谢!

UIGraphicsBeginImageContext(self.view.frame.size); [drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound); CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 5.0); CGContextSetAllowsAntialiasing(UIGraphicsGetCurrentContext(), YES); CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1.0, 0.0, 0.0, 1.0); CGContextBeginPath(UIGraphicsGetCurrentContext()); CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y); CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y); CGContextStrokePath(UIGraphicsGetCurrentContext()); drawImage.image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();

How do I draw a smooth line with a finger slide/touch motion on the iPhone? I have the following code but it is not smooth. It makes corners/turns for example when I try to do a circle. I think I have to use OpenGL. Any ideas? sample code? tutorials?

Thanks!

UIGraphicsBeginImageContext(self.view.frame.size); [drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound); CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 5.0); CGContextSetAllowsAntialiasing(UIGraphicsGetCurrentContext(), YES); CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1.0, 0.0, 0.0, 1.0); CGContextBeginPath(UIGraphicsGetCurrentContext()); CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y); CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y); CGContextStrokePath(UIGraphicsGetCurrentContext()); drawImage.image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();

最满意答案

我结束了使用Open GL和一个粒子。 检查这个的好例子是Apple的GLPaint示例代码。

I ended up using Open GL and a particle. Good example to check out for this is Apple's GLPaint example code.

更多推荐

本文发布于:2023-07-15 15:23:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1115299.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:平滑   用手指   画出   线条   iPhone

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!