DrawBot 0.9a2
DrawBot is an application for MacOSX in which you can write simple Python
programs that create two-dimensional graphics. It's mostly meant for
educational purposes: it should be easy to get started.
The main window contains three panes:
- A script pane on the top right. This is where you write your Python
program.
- A text output pane on the bottom right. This is where any textual output
of your program appears.
- A graphics pane, on the left. This is where you graphic appears.
Script pane features:
- Syntax coloring
- Auto indentation
- Dropping files or URL's: these will appear as Python string literals.
Graphics pane:
- Scrolling
- Save as PDF, Copy as PDF
- Drag as PDF: you can drag the graphic directly to other applications
accepting PDF data, for example Illustrator or iChat.
Currently DrawBot supports only very basic drawing primitives: you can draw
rectangles, ovals, polygons and bezier paths. RGB color is supported,
including transparency. Here's a short example that shows all builtin
possibilities:
r = Rect(10, 10, 50, 100) # (x, y, width, height)
r.fill() # fill the rectangle using the current color
c = Color(1, 0.5, 0) # create a color
c.set() # make this color the current color
r.setlinewidth(4) # specify a line width
r.stroke() # stroke the rectangle using the current color
o = Oval(10, 120, 100, 50)
o.fill()
c = Color(0.2, 0.5, 0.75)
c.set()
p = BezierPath() # create a new path
p.moveto(70, 10) # move the "pen" to (70, 10)
p.lineto(70, 100) # draw a line to (70, 100)
p.lineto(170, 100)
p.curveto(170, 40, 150, 10, 60, 10) # draw a curve
p.closepath()
p.fill()
A future version will also support drawing text and images as well as
transformations of the coordinate space.
Coordinates are specified in points (which correspond one on one with
pixels on MacOSX).
You can specify the canvas size by adding a special comment to the script
(typically at the top):
# size: 300 400
This will cause the canvas to be 300 points wide and 400 points high.
Advanced usage: DrawBot's graphics are implemented using Cocoa's drawing
features, but instead of using DrawBot's drawing primitives, you can also
use Cocoa directly.
----
DrawBot is written by Just van Rossum, just@letterror.com. There's a
minimal web page here: http://just.letterror.com/cgi-bin/wypy?DrawBot
DrawBot is released as open source, under an MIT-style license. It's a
Cocoa application written in Python, using PyObjC:
http://www.python.org/
http://pyobjc.sourceforge.net/
The source code requires Python.framework 2.3 and PyObjC 1.0rc3 or later.
To build DrawBot from the source, execute this command in the terminal in
the source directory:
python2.3 buildapp.py --link build