1

私にCGPathRefは5つの要素があり、開始点を削除したいのですが、開始点が削除したい開始点のパスの終了と同じである4つの要素を持つパスがあります。

これは、例外を生成する私の関数です。

static void constructPath(void *info, const CGPathElement *element) 
{
    NSBezierPath *bezierPath = (NSBezierPath *)info; 
    switch (element->type) {
        case kCGPathElementMoveToPoint:
            // some kind of skipping using points[0] kCGPathElementMoveToPoint
            [bezierPath lineToPoint:element->points[1]]; // line exception in gdb
            [bezierPath lineToPoint:element->points[2]];
            [bezierPath lineToPoint:element->points[3]];
            [bezierPath lineToPoint:element->points[4]];
            break;
        case kCGPathElementAddLineToPoint:

            if ([bezierPath isEmpty]) {
                [bezierPath moveToPoint:element->points[0]]; // the new start, how to go to next from here ?
            } else {

                [bezierPath moveToPoint:element->points[1]];
                [bezierPath moveToPoint:element->points[2]];
                [bezierPath moveToPoint:element->points[3]];
                [bezierPath moveToPoint:element->points[4]];
            }
            break;
        default:
            break;
    }
}
4

1 に答える 1

0

元のパスの最初の要素(タイプは)を無視してkCGPathElementMoveToPointください。次に、パスが空の場合を除いて、各行に新しい行を追加します。空の場合は、元のポイントに移動する必要があります。

static voidconstructPath(void * info、const CGPathElement * element)
{{
    NSBezierPath * bezierPath =(NSBezierPath *)info;
    if(kCGPathElementAddLineToPoint == element-> type)
    {{
        if([bezierPath isEmpty]){
            [bezierPath moveToPoint:element-> points [0]];
        } そうしないと {
            [bezierPath lineToPoint:element-> points [0]];
        }
    }
}
于 2012-06-25T16:05:03.917 に答える