Created
September 8, 2010 20:52
-
-
Save ccgus/570811 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function main() { | |
var doc = [Acorn open:"/Volumes/srv/Users/gus/Dropbox/AcornStuff/more junk.acorn"]; | |
var layer = [doc firstLayerNamed:"Background"]; | |
var canvasSize = [doc canvasSize]; | |
var inset = 40; | |
var image = [[[NSImage alloc] initWithSize:canvasSize] autorelease]; | |
var canvasBounds = NSMakeRect(0, 0, 0, 0); | |
canvasBounds.size = canvasSize; | |
var pageBounds = NSMakeRect(inset, -inset, canvasSize.width - inset * 2, canvasSize.height); | |
[image lockFocus]; | |
[[NSColor colorWithCalibratedWhite:0.908 alpha:1.000] set]; | |
[NSBezierPath fillRect:canvasBounds]; | |
var shadow = [[[NSShadow alloc] init] autorelease]; | |
[shadow setShadowColor:[[NSColor blackColor] colorWithAlphaComponent:.5]]; | |
[shadow setShadowBlurRadius:2]; | |
[[NSGraphicsContext currentContext] saveGraphicsState]; | |
[shadow set]; | |
[[NSColor whiteColor] set]; | |
var bp = [NSBezierPath bezierPathWithRoundedRect:pageBounds xRadius:16 yRadius:16]; | |
[bp fill]; | |
// get rid of our shadow | |
[[NSGraphicsContext currentContext] restoreGraphicsState]; | |
pageBounds = NSInsetRect(pageBounds, 1, 1); | |
pageBounds.origin.x -= .5; | |
pageBounds.origin.y += .5; | |
pageBounds.size.width += 1; | |
bp = [NSBezierPath bezierPathWithRoundedRect:pageBounds xRadius:16 yRadius:16]; | |
[[NSColor grayColor] set]; | |
[bp setLineWidth:1]; | |
[bp stroke]; | |
[image unlockFocus]; | |
[layer applyCIImageFromFilter:[image CIImage]]; | |
} | |
// are we running in Acorn? | |
if ("com.flyingmeat.Acorn" == [[NSBundle mainBundle] bundleIdentifier]) { | |
main(); | |
print("Done"); | |
} | |
else { // If not, then tell Acorn to run this guy. | |
[[JSTalk application:"Acorn"] doJavaScript:[jstalk env].scriptURL.path()]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment