Skip to content

Instantly share code, notes, and snippets.

@PsychoH13
Created July 9, 2010 03:47
Show Gist options
  • Save PsychoH13/469002 to your computer and use it in GitHub Desktop.
Save PsychoH13/469002 to your computer and use it in GitHub Desktop.
NSPoint PSYPointInBezierPath(NSPoint *points, NSInteger pointCount, CGFloat t,
NSPoint *getPoints, NSInteger getPointCount)
{
if(getPointCount > 0 && pointCount == getPointCount)
for(int i = 0; i < getPointCount; i++)
getPoints[i] = points[i];
if(pointCount <= 1) return *points;
NSPoint *newPoints = calloc(pointCount - 1, sizeof(NSPoint));
for(int i = 0; i < pointCount - 1; i++)
{
newPoints[i].x = t * (points[i+1].x - points[i].x) + points[i].x;
newPoints[i].y = t * (points[i+1].y - points[i].y) + points[i].y;
}
NSPoint ret = PSYPointInBezierPath(newPoints, pointCount - 1, t, getPoints, getPointCount);
free(newPoints);
return ret;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment