v0.3.15 Open source · MIT · Python 3.9+

A creative coding library for Python.

LineDream is inspired by Processing and P5. Each shape has its own style and transform methods, and everything saves to SVG.

$pip install LineDream
flow_field.py · 27 lines of Python · see the code

A quick example

Set the canvas size, add some shapes, rotate them, and save.

rectangles.py
from LineDream import Canvas, Rectangle

Canvas.width = 300
Canvas.height = 300
Canvas.background_color = '#263238'

for x in range(18):
	r = Rectangle(150, 150, 200, 200)
	r.rotate(10 * x)
	r.stroke_color = '#FFCB6B'

Canvas.save("rectangles.svg")
rectangles.svg

Plotter ready

LineDream was originally designed for pen plotters, so its SVGs work well on them out of the box. It's just as useful for general SVG creation.

Shapes are objects

Line, Circle, Rectangle, Arc and friends each carry their own stroke, fill and vertices. Subclass BaseShape to make your own.

Transform anything

Call rotate(), scale() or transform() on any shape, around any origin. No push/pop matrix bookkeeping.

Plotter-ready SVG

Set Canvas.units = 'mm' for real-world sizes, and use Group to export Inkscape layers, one per pen.

Single-stroke text

Text renders with Hershey fonts: lettering made of strokes, not outlines, so a pen draws each character once.

Get started

Install from PyPI, then work through the guide.

$pip install LineDream