gpt4 book ai didi

iphone - 在 iPhone 上用手指触摸绘制平滑的线条

转载 作者:行者123 更新时间:2023-12-03 19:32:30 25 4
gpt4 key购买 nike

如何在 iPhone 上通过手指滑动/触摸 Action 绘制平滑的线条?我有以下代码,但它并不顺利。例如,当我尝试绕圈时,它会产生拐角/转弯。我想我必须使用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();

最佳答案

我最终使用了 OpenGL 和粒子。 Apple 的 GLPaint 示例代码是一个很好的例子。

关于iphone - 在 iPhone 上用手指触摸绘制平滑的线条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2680206/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com