- Notifications
You must be signed in to change notification settings - Fork0
Simple creative coding Mojo 🔥 and Python lib
License
automata/basquiat
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Small Mojo 🔥 and Python library for creative coding powered byCairo (throughpycairo).The name is a humble homage to the artistJean-Michel Basquiat.
Both Mojo and Python implementations depend onpycairo
. I'm planning to migrateto cffilibcairo
directly from Mojo when possible, but we already have theMojo implementation running almost 3x faster than Python:
% time mojo rw.mojomojo rw.mojo 3.14s user 0.09s system 92% cpu 3.493 total% time python rw.pypython rw.py 8.69s user 0.15s system 126% cpu 6.990 total
Note: only a few drawing primitives are exposed from Cairo right now, butmore to come pretty soon!
For the Python version, create a virtual env and install the requirements.
python3 -m venv venvsource venv/bin/activatepip install --upgrade pippip install -r requirements.txt
For the Mojo version, please follow the instructions on Modular's websiteto get Mojo up and running. Make sure you havepycairo
installed as well.
Basquiat keeps the same API between Python and Mojo. The idea is toexpose a simpleRenderer
object that keeps the state of the canvasand implements drawing operations.
In Python:
frombasquiat.renderimportRendererr=Renderer(1024,1024)r.line(0,512,512,512)r.stroke()
In Mojo:
frombasquiat.renderimportRendererletr=Renderer(1024,1024)r.line(0,512,512,512)r.stroke()
Please check the examples (rw.{mojo,py}
,lines.{mojo,py}
) andalso the Mojo and Python implementations inbasquiat/
.
A couple of random walkers with 100k steps.
Inspired by Joy Division'sUnknown Pleasure album cover.
Some experiments with uniform and Perlin noise.