2

我在我的应用程序中使用核心图形进行绘图。

我想根据触摸速度画一条粗线或细线...

我编写了以下代码来绘制粗线或细线。

在我能够使用 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)
    {

    }
}
4

0 回答 0