<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>AppKit/CPBezierPath.j</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -590,6 +590,28 @@ url(&quot;data:image/png;base64,BASE64ENCODEDDATA&quot;)  // if there is a pattern image
 
 @end
 
+@implementation CPColor (CoreGraphicsExtensions)
+
+- (void)set
+{
+    [self setFill];
+    [self setStroke];
+}
+
+- (void)setFill
+{
+    var ctx = [[CPGraphicsContext currentContext] graphicsPort];
+    CGContextSetFillColor(ctx, self);   
+}
+
+- (void)setStroke
+{
+    var ctx = [[CPGraphicsContext currentContext] graphicsPort];
+    CGContextSetStrokeColor(ctx, self);
+}
+
+@end
+
 var CPColorComponentsKey    = @&quot;CPColorComponentsKey&quot;,
     CPColorPatternImageKey  = @&quot;CPColorPatternImageKey&quot;;
 </diff>
      <filename>AppKit/CPColor.j</filename>
    </modified>
    <modified>
      <diff>@@ -459,24 +459,7 @@ var KAPPA = 4.0 * ((SQRT2 - 1.0) / 3.0);
 */
 function CGContextAddEllipseInRect(aContext, aRect)
 {
-	CGContextBeginPath(aContext);
-	
-	if (_CGRectGetWidth(aRect) == _CGRectGetHeight(aRect))
-	    CGContextAddArc(aContext, _CGRectGetMidX(aRect), _CGRectGetMidY(aRect), _CGRectGetWidth(aRect) / 2.0, 0.0, 2 * PI, YES);
-	else
-	{
-	    var axis = _CGSizeMake(_CGRectGetWidth(aRect) / 2.0, _CGRectGetHeight(aRect) / 2.0),
-	        center = _CGPointMake(_CGRectGetMinX(aRect) + axis.width, _CGRectGetMinY(aRect) + axis.height);
-	
-	    CGContextMoveToPoint(aContext, center.x, center.y - axis.height);
-	
-	    CGContextAddCurveToPoint(aContext, center.x + (KAPPA * axis.width), center.y - axis.height,  center.x + axis.width, center.y - (KAPPA * axis.height), center.x + axis.width, center.y);
-	    CGContextAddCurveToPoint(aContext, center.x + axis.width, center.y + (KAPPA * axis.height), center.x + (KAPPA * axis.width), center.y + axis.height, center.x, center.y + axis.height);
-	    CGContextAddCurveToPoint(aContext, center.x - (KAPPA * axis.width), center.y + axis.height, center.x - axis.width, center.y + (KAPPA * axis.height), center.x - axis.width, center.y);
-	    CGContextAddCurveToPoint(aContext, center.x - axis.width, center.y - (KAPPA * axis.height), center.x - (KAPPA * axis.width), center.y - axis.height, center.x, center.y - axis.height);
-	}
-	
-	CGContextClosePath(aContext);
+    CGContextAddPath(aContext, CGPathWithEllipseInRect(aRect));
 }
 
 /*!
@@ -589,93 +572,13 @@ function CGContextSetStrokeColor(aContext, aColor)
 */
 function CGContextFillRoundedRectangleInRect(aContext, aRect, aRadius, ne, se, sw, nw)
 {
-    var xMin = _CGRectGetMinX(aRect),
-        xMax = _CGRectGetMaxX(aRect),
-        yMin = _CGRectGetMinY(aRect),
-        yMax = _CGRectGetMaxY(aRect);
-
-    CGContextBeginPath(aContext);
-    CGContextMoveToPoint(aContext, xMin + aRadius, yMin);
-	
-	if (ne)
-	{
-		CGContextAddLineToPoint(aContext, xMax - aRadius, yMin);
-		CGContextAddCurveToPoint(aContext, xMax - aRadius, yMin, xMax, yMin, xMax, yMin + aRadius);
-	}
-	else
-		CGContextAddLineToPoint(aContext, xMax, yMin);
-	
-	if (se)
-	{
-		CGContextAddLineToPoint(aContext, xMax, yMax - aRadius);
-		CGContextAddCurveToPoint(aContext, xMax, yMax - aRadius, xMax, yMax, xMax - aRadius, yMax);
-	}
-	else
-		CGContextAddLineToPoint(aContext, xMax, yMax);
-	
-	if (sw)
-	{
-		CGContextAddLineToPoint(aContext, xMin + aRadius, yMax);
-		CGContextAddCurveToPoint(aContext, xMin + aRadius, yMax, xMin, yMax, xMin, yMax - aRadius);
-	}
-	else
-		CGContextAddLineToPoint(aContext, xMin, yMax);
-	
-	if (nw)
-	{
-		CGContextAddLineToPoint(aContext, xMin, yMin + aRadius);
-		CGContextAddCurveToPoint(aContext, xMin, yMin + aRadius, xMin, yMin, xMin + aRadius, yMin);
-	} else
-		CGContextAddLineToPoint(aContext, xMin, yMin);
-	
-	CGContextClosePath(aContext);
-	
+    CGContextAddPath(aContext, CGPathWithRoundedRectangleInRect(aRect, aRadius, aRadius, ne, se, sw, nw));	
     CGContextFillPath(aContext);
 }
 
 function CGContextStrokeRoundedRectangleInRect(aContext, aRect, aRadius, ne, se, sw, nw)
 {
-    var xMin = _CGRectGetMinX(aRect),
-        xMax = _CGRectGetMaxX(aRect),
-        yMin = _CGRectGetMinY(aRect),
-        yMax = _CGRectGetMaxY(aRect);
-
-    CGContextBeginPath(aContext);
-    CGContextMoveToPoint(aContext, xMin + aRadius, yMin);
-	
-	if (ne)
-	{
-		CGContextAddLineToPoint(aContext, xMax - aRadius, yMin);
-		CGContextAddCurveToPoint(aContext, xMax - aRadius, yMin, xMax, yMin, xMax, yMin + aRadius);
-	}
-	else
-		CGContextAddLineToPoint(aContext, xMax, yMin);
-	
-	if (se)
-	{
-		CGContextAddLineToPoint(aContext, xMax, yMax - aRadius);
-		CGContextAddCurveToPoint(aContext, xMax, yMax - aRadius, xMax, yMax, xMax - aRadius, yMax);
-	}
-	else
-		CGContextAddLineToPoint(aContext, xMax, yMax);
-	
-	if (sw)
-	{
-		CGContextAddLineToPoint(aContext, xMin + aRadius, yMax);
-		CGContextAddCurveToPoint(aContext, xMin + aRadius, yMax, xMin, yMax, xMin, yMax - aRadius);
-	}
-	else
-		CGContextAddLineToPoint(aContext, xMin, yMax);
-	
-	if (nw)
-	{
-		CGContextAddLineToPoint(aContext, xMin, yMin + aRadius);
-		CGContextAddCurveToPoint(aContext, xMin, yMin + aRadius, xMin, yMin, xMin + aRadius, yMin);
-	} else
-		CGContextAddLineToPoint(aContext, xMin, yMin);
-	
-	CGContextClosePath(aContext);
-	
+    CGContextAddPath(aContext, CGPathWithRoundedRectangleInRect(aRect, aRadius, aRadius, ne, se, sw, nw));		
     CGContextStrokePath(aContext);
 }
 </diff>
      <filename>AppKit/CoreGraphics/CGContext.j</filename>
    </modified>
    <modified>
      <diff>@@ -158,12 +158,15 @@ function CGPathAddPath(aPath, aTransform, anotherPath)
         
     for (; i &lt; count; ++i)
     {
-        var element = anotherPath[i];
+        var element = anotherPath.elements[i];
         
-        aPath.elements[aPath.count++] = { type:element.type, points:element.point.slice() };
+        aPath.elements[aPath.count] = { type:element.type, x:element.x, y:element.y, 
+                                        cpx:element.cpx, cpy:element.cpy, 
+                                        radius:element.radius, startAngle:element.startAngle, endAngle:element.endAngle, 
+                                        cp1x:element.cp1x, cp1y:element.cp1y, cp2x:element.cp2x, cp2y:element.cp2y,
+                                        points: element.points ? element.points.slice() : nil};
         
-        if (element.type == kCGPathElementAddArc || element.type == kCGPathElementAddArcToPoint)
-            aPath.elements[aPath.count - 1].radius = element.radius;
+        aPath.count++
     }
     
     aPath.current = anotherPath.current;
@@ -231,6 +234,76 @@ function CGPathMoveToPoint(aPath, aTransform, x, y)
         aPath.elements[aPath.count++] = { type:kCGPathElementMoveToPoint, x:point.x, y:point.y };
 }
 
+function CGPathWithEllipseInRect(aRect)
+{
+    var path = CGPathCreateMutable();
+	
+	if (_CGRectGetWidth(aRect) == _CGRectGetHeight(aRect))
+        CGPathAddArc(path, nil, _CGRectGetMidX(aRect), _CGRectGetMidY(aRect), _CGRectGetWidth(aRect) / 2.0, 0.0, 2 * PI, YES);
+	else
+	{
+	    var axis = _CGSizeMake(_CGRectGetWidth(aRect) / 2.0, _CGRectGetHeight(aRect) / 2.0),
+	        center = _CGPointMake(_CGRectGetMinX(aRect) + axis.width, _CGRectGetMinY(aRect) + axis.height);
+
+        CGPathMoveToPoint(path, nil, center.x, center.y - axis.height);
+	
+	    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);
+	    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);
+	    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);
+	    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);
+	}
+
+    CGPathCloseSubpath(path);
+
+    return path;
+}
+
+function CGPathWithRoundedRectangleInRect(aRect, xRadius, yRadius/*not currently supported*/, ne, se, sw, nw)
+{
+    var path = CGPathCreateMutable(),
+        xMin = _CGRectGetMinX(aRect),
+        xMax = _CGRectGetMaxX(aRect),
+        yMin = _CGRectGetMinY(aRect),
+        yMax = _CGRectGetMaxY(aRect);
+
+    CGPathMoveToPoint(path, nil, xMin + xRadius, yMin);
+	
+	if (ne)
+	{
+		CGPathAddLineToPoint(path, nil, xMax - xRadius, yMin);
+		CGPathAddCurveToPoint(path, nil, xMax - xRadius, yMin, xMax, yMin, xMax, yMin + xRadius);
+	}
+	else
+		CGPathAddLineToPoint(path, nil, xMax, yMin);
+	
+	if (se)
+	{
+		CGPathAddLineToPoint(path, nil, xMax, yMax - xRadius);
+		CGPathAddCurveToPoint(path, nil, xMax, yMax - xRadius, xMax, yMax, xMax - xRadius, yMax);
+	}
+	else
+		CGPathAddLineToPoint(path, nil, xMax, yMax);
+	
+	if (sw)
+	{
+		CGPathAddLineToPoint(path, nil, xMin + xRadius, yMax);
+		CGPathAddCurveToPoint(path, nil, xMin + xRadius, yMax, xMin, yMax, xMin, yMax - xRadius);
+	}
+	else
+		CGPathAddLineToPoint(path, nil, xMin, yMax);
+	
+	if (nw)
+	{
+		CGPathAddLineToPoint(path, nil, xMin, yMin + xRadius);
+		CGPathAddCurveToPoint(path, nil, xMin, yMin + xRadius, xMin, yMin, xMin + xRadius, yMin);
+	} else
+		CGPathAddLineToPoint(path, nil, xMin, yMin);
+
+    CGPathCloseSubpath(path);
+
+    return path;
+}
+
 function CGPathCloseSubpath(aPath)
 {
     var count = aPath.count;</diff>
      <filename>AppKit/CoreGraphics/CGPath.j</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>22f7985d2088dc3276434976c47d8ff106788b02</id>
    </parent>
  </parents>
  <author>
    <name>Ross Boucher</name>
    <email>ross@280north.com</email>
  </author>
  <url>http://github.com/280north/cappuccino/commit/9c7f07979b3a228a64521a950e971820cf46fd8d</url>
  <id>9c7f07979b3a228a64521a950e971820cf46fd8d</id>
  <committed-date>2009-05-14T19:06:58-07:00</committed-date>
  <authored-date>2009-05-14T19:06:58-07:00</authored-date>
  <message>Add CPBezierPath, clean up some of CGPath and CGContext</message>
  <tree>0fe6cd1f2b91364efe8d8029128bd4336f42b37f</tree>
  <committer>
    <name>Ross Boucher</name>
    <email>ross@280north.com</email>
  </committer>
</commit>
