我正在使用核心图形绘制我的应用程序。
我想根据触摸速度绘制粗线或细线......
我已经编写了以下用于绘制粗线或细线的代码。
在我能够使用panGestureRecognizer跟踪速度并且我已经应用了它,对于线宽,因此我能够根据触摸的速度绘制粗细线。
但主要的问题是绘制的线条看起来不是很平滑。
如果我顺利画出成功的粗线或细线,那就太棒了。
- (void)handlePanGesture:(UIPanGestureRecognizer *)panGestureRecognizer
{
if (panGestureRecognizer.state == UIGestureRecognizerStateBegan)
{
// retrieve touch point
currentPoint = [panGestureRecognizer locationInView:panGestureRecognizer.view];
previousPoint = currentPoint;
}
if (panGestureRecognizer.state == UIGestureRecognizerStateChanged)
{
currentPoint = [panGestureRecognizer locationInView:panGestureRecognizer.view];
previousPoint = currentPoint;
float vel = [self ccpLength:[panGestureRecognizer velocityInView:panGestureRecognizer.view]];
tmplinewidth = vel / 166.0f;
tmplinewidth = clampf(tmplinewidth, 2, 20);
}
if (panGestureRecognizer.state == UIGestureRecognizerStateEnded)
{
}
}