May 30, 2007

CoreGraphics Programming Prototyping with Python

Filed under: General Information — Ryan Wilcox @ 8:33 pm

Every once in a while I have to write some Core Graphics code. (Lately it’s been code to draw custom HIView subclasses, but I digress).

I only do this once in a while, so I always spend some time fighting with primitives and coordinates and just drawing. In C based languages a change in a source file means a whole new compile-link-run cycle, and if your application is big this could mean a minute or two waiting, and a minute getting to the right spot – just to find out that “nope, that doesn’t work”.

There’s a better way: Python. DrawBot and NodeBox.

The drawing API of DrawBot (and NodeBox, which is based off DrawBot code) feels a lot like Core Graphics’ NSGraphicsContext/CGGraphicsContext APIs (thanks to their OS X and Quartz heritage, no doubt). Meaning that you can try CoreGraphics code out (almost) interactively.

Using DrawBot’s thinly veiled CoreGraphics API you can type some code, run your Python code, and the result is displayed in a little pane beside the code browser. No compile cycle, no making a New Project in XCode so you can test your code quickly: just type, run look. Nothing could be simpler.

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment