Created
December 17, 2011 15:21
-
-
Save pita5/1490480 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void clipApplier(void *info, const CGPathElement *element) | |
{ | |
NSMutableArray *a = (NSMutableArray*)info; | |
int nPoints; | |
switch (element->type) | |
{ | |
case kCGPathElementMoveToPoint: | |
nPoints = 1; | |
break; | |
case kCGPathElementAddLineToPoint: | |
nPoints = 1; | |
break; | |
case kCGPathElementAddQuadCurveToPoint: | |
nPoints = 2; | |
break; | |
case kCGPathElementAddCurveToPoint: | |
nPoints = 3; | |
break; | |
case kCGPathElementCloseSubpath: | |
nPoints = 0; | |
break; | |
default: | |
[a replaceObjectAtIndex:0 withObject:[NSNumber numberWithBool:NO]]; | |
return; | |
} | |
if (nPoints > 0) | |
{ | |
CGPoint *p = element->points; | |
for (int i = 0; i < nPoints; i++) | |
{ | |
if (p->x > 320 || p->x < 0 || p->y < 0 || p->y > 460) | |
return; | |
p++; | |
} | |
} | |
NSNumber *type = [NSNumber numberWithInt:element->type]; | |
NSData *points = [NSData dataWithBytes:element->points length:nPoints*sizeof(CGPoint)]; | |
[a addObject:[NSDictionary dictionaryWithObjectsAndKeys:type,@"type",points,@"points",nil]]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment