45 return { count:0,
start:CGPointMake(0, 0), current:CGPointMake(0, 0), elements:[] };
79 function CGPathAddArc(aPath, aTransform, x, y, aRadius, aStartAngle, anEndAngle, isClockwise)
83 var center = CGPointMake(x, y),
84 end = CGPointMake(COS(anEndAngle), SIN(anEndAngle)),
85 start = CGPointMake(COS(aStartAngle), SIN(aStartAngle));
94 var oldEndAngle = anEndAngle,
95 oldStartAngle = aStartAngle;
97 anEndAngle = ATAN2(end.y - aTransform.ty, end.x - aTransform.tx);
98 aStartAngle = ATAN2(
start.y - aTransform.ty,
start.x - aTransform.tx);
103 if (anEndAngle === aStartAngle && oldEndAngle !== oldStartAngle)
104 if (oldStartAngle > oldEndAngle)
105 anEndAngle = anEndAngle - PI2;
107 aStartAngle = aStartAngle - PI2;
109 aRadius = CGSizeMake(aRadius, 0);
111 aRadius = SQRT(aRadius.width * aRadius.width + aRadius.height * aRadius.height);
121 var arcEndX = x + aRadius * COS(anEndAngle),
122 arcEndY = y + aRadius * SIN(anEndAngle),
123 arcStartX = x + aRadius * COS(aStartAngle),
124 arcStartY = y + aRadius * SIN(aStartAngle);
128 if (aPath.current.x !== x || aPath.current.y !== y)
133 aPath.start = CGPointMake(arcStartX, arcStartY);
136 aPath.current = CGPointMake(arcEndX, arcEndY);
137 aPath.elements[aPath.count++] = { type:
kCGPathElementAddArc, x:x, y:y, radius:aRadius, startAngle:aStartAngle, endAngle:anEndAngle, isClockwise:isClockwise };
142 var p1 = CGPointMake(x1, y1),
143 p2 = CGPointMake(x2, y2);
160 if (aPath.current.x !== p1.x || aPath.current.y !== p1.y)
172 var cp1 = CGPointMake(cp1x, cp1y),
173 cp2 = CGPointMake(cp2x, cp2y),
174 end = CGPointMake(x, y);
189 if (count === null || count === undefined)
190 count = points.length;
192 if (!aPath || count < 1)
197 for (var i = 1; i < count; ++i)
203 var point = CGPointMake(x, y);
205 if (aTransform !== NULL)
209 aPath.current = point;
214 for (var i = 0, count = anotherPath.count; i < count; ++i)
216 var element = anotherPath.elements[i];
218 switch (element.type)
226 element.cp1x, element.cp1y,
227 element.cp2x, element.cp2y,
228 element.x, element.y);
233 element.radius, element.startAngle,
234 element.endAngle, element.isClockwise);
239 element.p1x, element.p1y,
240 element.p2x, element.p2y,
246 element.cpx, element.cpy,
247 element.x, element.y);
263 var cp = CGPointMake(cpx, cpy),
264 end = CGPointMake(x, y);
286 var count = rects.length;
288 for (; i < count; ++i)
303 var point = CGPointMake(x, y);
305 if (aTransform !== NULL)
308 aPath.start = aPath.current = point;
313 var previous = aPath.elements[aPath.count - 1];
317 previous.x = point.x;
318 previous.y = point.y;
326 var
KAPPA = 4.0 * ((SQRT2 - 1.0) / 3.0);
332 if (CGRectGetWidth(aRect) === CGRectGetHeight(aRect))
333 CGPathAddArc(path, nil, CGRectGetMidX(aRect), CGRectGetMidY(aRect), CGRectGetWidth(aRect) / 2.0, 0.0, 2 * PI, YES);
336 var axis = CGSizeMake(CGRectGetWidth(aRect) / 2.0, CGRectGetHeight(aRect) / 2.0),
337 center = CGPointMake(CGRectGetMinX(aRect) + axis.width, CGRectGetMinY(aRect) + axis.height);
341 CGPathAddCurveToPoint(path, nil, center.x + (
KAPPA * axis.width), center.y - axis.height, center.x + axis.width, center.y - (
KAPPA * axis.height), center.x + axis.width, center.y);
342 CGPathAddCurveToPoint(path, nil, center.x + axis.width, center.y + (
KAPPA * axis.height), center.x + (
KAPPA * axis.width), center.y + axis.height, center.x, center.y + axis.height);
343 CGPathAddCurveToPoint(path, nil, center.x - (
KAPPA * axis.width), center.y + axis.height, center.x - axis.width, center.y + (
KAPPA * axis.height), center.x - axis.width, center.y);
344 CGPathAddCurveToPoint(path, nil, center.x - axis.width, center.y - (
KAPPA * axis.height), center.x - (
KAPPA * axis.width), center.y - axis.height, center.x, center.y - axis.height);
355 xMin = CGRectGetMinX(aRect),
356 xMax = CGRectGetMaxX(aRect),
357 yMin = CGRectGetMinY(aRect),
358 yMax = CGRectGetMaxY(aRect);
401 var count = aPath.count;
408 aPath.current = CGPointCreateCopy(aPath.start);
414 if (aPath === anotherPath)
417 if (aPath.count !== anotherPath.count || !CGPointEqualToPoint(aPath.start, anotherPath.start) || !CGPointEqualToPoint(aPath.current, anotherPath.current))
423 for (; i < count; ++i)
425 var element = aPath[i],
426 anotherElement = anotherPath[i];
428 if (element.type !== anotherElement.type)
431 switch (element.type)
434 if (element.x !== anotherElement.x ||
435 element.y !== anotherElement.y ||
436 element.radius !== anotherElement.radius ||
437 element.startAngle !== anotherElement.startAngle ||
438 element.endAngle !== anotherElement.endAngle ||
439 element.isClockwise !== anotherElement.isClockwise)
446 if (element.p1x !== anotherElement.p1x ||
447 element.p1y !== anotherElement.p1y ||
448 element.p2x !== anotherElement.p2x ||
449 element.p2y !== anotherElement.p2y ||
450 element.radius !== anotherElement.radius)
457 if (element.cp1x !== anotherElement.cp1x ||
458 element.cp1y !== anotherElement.cp1y ||
459 element.cp2x !== anotherElement.cp2x ||
460 element.cp2y !== anotherElement.cp2y ||
461 element.x !== anotherElement.x ||
462 element.y !== anotherElement.y)
470 if (element.x !== anotherElement.x ||
471 element.y !== anotherElement.y)
478 if (element.cpx !== anotherElement.cpx ||
479 element.cpy !== anotherElement.cpy ||
480 element.x !== anotherElement.x ||
481 element.y !== anotherElement.y)
488 if (!CGPointEqualToPoint(element.start, anotherElement.start))
499 return CGPointCreateCopy(aPath.current);
504 return !aPath || aPath.count === 0;
512 if (!aPath || !aPath.count)
513 return CGRectMakeZero();
521 function addPoint(x, y)
529 for (var i = 0, count = aPath.count; i < count; ++i)
531 var element = aPath.elements[i];
535 switch (element.type)
540 addPoint(movePoint.x, movePoint.y);
544 addPoint(element.x, element.y);
550 addPoint(movePoint.x, movePoint.y);
554 addPoint(element.cp1x, element.cp1y);
555 addPoint(element.cp2x, element.cp2y);
556 addPoint(element.x, element.y);
562 addPoint(movePoint.x, movePoint.y);
566 addPoint(element.x, element.y);
572 addPoint(movePoint.x, movePoint.y);
576 addPoint(element.p1x, element.p1y);
577 addPoint(element.p2x, element.p2y);
583 addPoint(movePoint.x, movePoint.y);
587 addPoint(element.cpx, element.cpy);
588 addPoint(element.x, element.y);
592 movePoint = CGPointMake(element.x, element.y);
598 addPoint(movePoint.x, movePoint.y);
606 return CGRectMake(ox, oy, rx - ox, ry - oy);
623 return context.isPointInPath(point.x, point.y);
function CGPathWithRoundedRectangleInRect(aRect, xRadius, yRadius, ne, se, sw, nw)
CGPath kCGPathElementMoveToPoint
function CGPathGetBoundingBox(aPath)
function CGPathCloseSubpath(aPath)
function CGPathEqualToPath(aPath, anotherPath)
function CGPathAddRects(aPath, aTransform, rects, count)
function CGPathCreateCopy(aPath)
kCGPathElementAddLineToPoint
function CGContextClosePath(aContext)
function CGPathMoveToPoint(aPath, aTransform, x, y)
kCGPathElementAddArcToPoint
function CGPathAddLines(aPath, aTransform, points, count)
function CGPathAddCurveToPoint(aPath, aTransform, cp1x, cp1y, cp2x, cp2y, x, y)
function CGContextAddPath(aContext, aPath)
function CGPathWithEllipseInRect(aRect)
function CGPathIsEmpty(aPath)
function CGPathAddArc(aPath, aTransform, x, y, aRadius, aStartAngle, anEndAngle, isClockwise)
kCGPathElementCloseSubpath
function CGContextBeginPath(aContext)
function CGPathCreateMutable()
function CGPathAddRect(aPath, aTransform, aRect)
function CGPathCreateMutableCopy(aPath)
function CGPathGetCurrentPoint(aPath)
function CGPathRetain(aPath)
function CGPathRelease(aPath)
kCGPathElementAddCurveToPoint
FrameUpdater prototype start
function CGPathAddLineToPoint(aPath, aTransform, x, y)
kCGPathElementAddQuadCurveToPoint
function CGPathContainsPoint(aPath, aTransform, point, eoFill)
function CGBitmapGraphicsContextCreate()
function CGPathAddPath(aPath, aTransform, anotherPath)
function CGPathAddArcToPoint(aPath, aTransform, x1, y1, x2, y2, aRadius)
function CGPathAddQuadCurveToPoint(aPath, aTransform, cpx, cpy, x, y)