diff --git a/AppKit/CoreGraphics/CGPath.j b/AppKit/CoreGraphics/CGPath.j index 05d1651d8..eff048332 100644 --- a/AppKit/CoreGraphics/CGPath.j +++ b/AppKit/CoreGraphics/CGPath.j @@ -120,12 +120,14 @@ function CGPathAddArc(aPath, aTransform, x, y, aRadius, aStartAngle, anEndAngle, The ending point of the arc becomes the new current point of the path. */ var arcEndX = x + aRadius * COS(anEndAngle), - arcEndY = y + aRadius * SIN(anEndAngle); + arcEndY = y + aRadius * SIN(anEndAngle), + arcStartX = x + aRadius * COS(aStartAngle), + arcStartY = y + aRadius * SIN(aStartAngle); if (aPath.count) { - if (aPath.current.x !== arcEndX || aPath.current.y !== arcEndY) - CGPathAddLineToPoint(aPath, aTransform, arcEndX, arcEndY); + if (aPath.current.x !== x || aPath.current.y !== y) + CGPathAddLineToPoint(aPath, aTransform, arcStartX, arcStartY); } else { diff --git a/Tests/Manual/CGPath/AppController.j b/Tests/Manual/CGPath/AppController.j new file mode 100644 index 000000000..62d683374 --- /dev/null +++ b/Tests/Manual/CGPath/AppController.j @@ -0,0 +1,92 @@ +/* + * AppController.j + * CGPath + * + * Created by You on May 23, 2013. + * Copyright 2013, Your Company All rights reserved. + */ + +@import +@import + +@implementation AppController : CPObject +{ +} + +- (void)applicationDidFinishLaunching:(CPNotification)aNotification +{ + var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask], + contentView = [theWindow contentView]; + + var label = [[CPTextField alloc] initWithFrame:CGRectMakeZero()]; + + [label setStringValue:@"Hello World!"]; + [label setFont:[CPFont boldSystemFontOfSize:24.0]]; + + [label sizeToFit]; + + [label setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin | CPViewMinYMargin | CPViewMaxYMargin]; + [label setCenter:[contentView center]]; + + [contentView addSubview:label]; + + var pathView = [[PathView alloc] initWithFrame:CGRectMake(0.0, 0.0, 500.0, 500.0)]; + [contentView addSubview:pathView]; + + [theWindow orderFront:self]; + + // Uncomment the following line to turn on the standard menu bar. + //[CPMenu setMenuBarVisible:YES]; +} + +@end + +@implementation PathView : CPView +{ +} + +- (id)init +{ + if(self = [super init]) + { + } + return self; +} + +- (void)drawRect:(CGRect)aRect +{ + var context = [[CPGraphicsContext currentContext] graphicsPort]; + + // Test to create a pie chart + CGContextBeginPath(context); + var path = CGPathCreateMutable(); + CGPathMoveToPoint(path, nil, 100, 100); + CGPathAddArc(path, nil,100, 100, 70, 0, 2.615500255957057, YES); + CGPathAddLineToPoint(path, nil, 100, 100); + CGPathAddArc(path, nil,100, 100, 70, 2.615500255957057, 6.148960361810042, YES); + CGPathAddLineToPoint(path, nil, 100, 100); + CGPathAddArc(path, nil,100, 100, 70, 6.148960361810042, 0, YES); + CGPathAddLineToPoint(path, nil, 100, 100); + CGContextAddPath(context, path); + CGContextStrokePath(context); + CGContextClosePath(context); + + // Test to create an arc without a start point + CGContextBeginPath(context); + path = CGPathCreateMutable(); + CGPathAddArc(path, nil,300, 100, 70, 0, 2.615500255957057, YES); + CGContextAddPath(context, path); + CGContextStrokePath(context); + CGContextClosePath(context); + + // Test to create an arc with a start point + CGContextBeginPath(context); + path = CGPathCreateMutable(); + CGPathMoveToPoint(path, nil, 100, 250); + CGPathAddArc(path, nil,100, 300, 70, 0, 2.615500255957057, YES); + CGContextAddPath(context, path); + CGContextStrokePath(context); + CGContextClosePath(context); +} + +@end diff --git a/Tests/Manual/CGPath/Info.plist b/Tests/Manual/CGPath/Info.plist new file mode 100644 index 000000000..48b1a0402 --- /dev/null +++ b/Tests/Manual/CGPath/Info.plist @@ -0,0 +1,12 @@ + + + + + CPApplicationDelegateClass + AppController + CPBundleName + CGPath + CPPrincipalClass + CPApplication + + diff --git a/Tests/Manual/CGPath/Jakefile b/Tests/Manual/CGPath/Jakefile new file mode 100644 index 000000000..6d194c99d --- /dev/null +++ b/Tests/Manual/CGPath/Jakefile @@ -0,0 +1,98 @@ +/* + * Jakefile + * CGPath + * + * Created by You on May 23, 2013. + * Copyright 2013, Your Company All rights reserved. + */ + +var ENV = require("system").env, + FILE = require("file"), + JAKE = require("jake"), + task = JAKE.task, + FileList = JAKE.FileList, + app = require("cappuccino/jake").app, + configuration = ENV["CONFIG"] || ENV["CONFIGURATION"] || ENV["c"] || "Debug", + OS = require("os"); + +app ("CGPath", function(task) +{ + ENV["OBJJ_INCLUDE_PATHS"] = "Frameworks"; + + if (configuration === "Debug") + ENV["OBJJ_INCLUDE_PATHS"] = FILE.join(ENV["OBJJ_INCLUDE_PATHS"], configuration); + + task.setBuildIntermediatesPath(FILE.join("Build", "CGPath.build", configuration)); + task.setBuildPath(FILE.join("Build", configuration)); + + task.setProductName("CGPath"); + task.setIdentifier("com.yourcompany.CGPath"); + task.setVersion("1.0"); + task.setAuthor("Your Company"); + task.setEmail("feedback @nospam@ yourcompany.com"); + task.setSummary("CGPath"); + task.setSources(new FileList("**/*.j").exclude(FILE.join("Build", "**")).exclude(FILE.join("Frameworks", "Source", "**"))); + task.setResources(new FileList("Resources/**")); + task.setIndexFilePath("index.html"); + task.setInfoPlistPath("Info.plist"); + + if (configuration === "Debug") + task.setCompilerFlags("-DDEBUG -g"); + else + task.setCompilerFlags("-O"); +}); + +task ("default", ["CGPath"], function() +{ + printResults(configuration); +}); + +task ("build", ["default"]); + +task ("debug", function() +{ + ENV["CONFIGURATION"] = "Debug"; + JAKE.subjake(["."], "build", ENV); +}); + +task ("release", function() +{ + ENV["CONFIGURATION"] = "Release"; + JAKE.subjake(["."], "build", ENV); +}); + +task ("run", ["debug"], function() +{ + OS.system(["open", FILE.join("Build", "Debug", "CGPath", "index.html")]); +}); + +task ("run-release", ["release"], function() +{ + OS.system(["open", FILE.join("Build", "Release", "CGPath", "index.html")]); +}); + +task ("deploy", ["release"], function() +{ + FILE.mkdirs(FILE.join("Build", "Deployment", "CGPath")); + OS.system(["press", "-f", FILE.join("Build", "Release", "CGPath"), FILE.join("Build", "Deployment", "CGPath")]); + printResults("Deployment") +}); + +task ("desktop", ["release"], function() +{ + FILE.mkdirs(FILE.join("Build", "Desktop", "CGPath")); + require("cappuccino/nativehost").buildNativeHost(FILE.join("Build", "Release", "CGPath"), FILE.join("Build", "Desktop", "CGPath", "CGPath.app")); + printResults("Desktop") +}); + +task ("run-desktop", ["desktop"], function() +{ + OS.system([FILE.join("Build", "Desktop", "CGPath", "CGPath.app", "Contents", "MacOS", "NativeHost"), "-i"]); +}); + +function printResults(configuration) +{ + print("----------------------------"); + print(configuration+" app built at path: "+FILE.join("Build", configuration, "CGPath")); + print("----------------------------"); +} diff --git a/Tests/Manual/CGPath/Resources/spinner.gif b/Tests/Manual/CGPath/Resources/spinner.gif new file mode 100644 index 000000000..a5e705f6c Binary files /dev/null and b/Tests/Manual/CGPath/Resources/spinner.gif differ diff --git a/Tests/Manual/CGPath/index-debug.html b/Tests/Manual/CGPath/index-debug.html new file mode 100644 index 000000000..80c7219c9 --- /dev/null +++ b/Tests/Manual/CGPath/index-debug.html @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + CGPath + + + + + + + + + + + + + + +
+
+ + + +
+
+ + + diff --git a/Tests/Manual/CGPath/index.html b/Tests/Manual/CGPath/index.html new file mode 100644 index 000000000..1fa069702 --- /dev/null +++ b/Tests/Manual/CGPath/index.html @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + CGPath + + + + + + + + + + + + +
+
+ + + +
+
+ + + + diff --git a/Tests/Manual/CGPath/main.j b/Tests/Manual/CGPath/main.j new file mode 100644 index 000000000..a7bb6a144 --- /dev/null +++ b/Tests/Manual/CGPath/main.j @@ -0,0 +1,18 @@ +/* + * AppController.j + * CGPath + * + * Created by You on May 23, 2013. + * Copyright 2013, Your Company All rights reserved. + */ + +@import +@import + +@import "AppController.j" + + +function main(args, namedArgs) +{ + CPApplicationMain(args, namedArgs); +}