[Pyobjc-dev] Quartz python bindings
Brought to you by:
ronaldoussoren
|
From: Orestis M. <or...@or...> - 2009-04-05 12:58:57
|
Hi there, I just came across this: http://developer.apple.com/graphicsimaging/pythonandquartz.html Which describes a set of nice pythonic APIs for Quartz. Example: # step 1: import the required modules from CoreGraphics import * import math # step 2: create the bitmap context # NOTE: on Panther use cs = CGColorSpaceCreateDeviceRGB() cs = CGColorSpaceCreateWithName( kCGColorSpaceGenericRGB ) c = CGBitmapContextCreateWithColor( 256, 256, cs, (0,0,0,0) ) # step 3: draw a yellow square with a red outline c.saveGState() c.setRGBStrokeColor(1,0,0,1) # red c.setRGBFillColor(1,1,0,1) # yellow c.setLineWidth(3) c.setLineJoin(kCGLineJoinBevel) c.addRect( CGRectMake( 32.5, 32.5, 191, 191 ) ) c.drawPath( kCGPathFillStroke ); c.restoreGState() # step 4: write out the file in PNG format c.writeToFile ("out.png", kCGImageFormatPNG) I was wondering if this is: a) Part of PyObjC (it seems not) b) up-to-date c) recommended to use d) open-source Any ideas? Thanks, Orestis -- or...@or... http://orestis.gr/ |