Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Simple creative coding Mojo 🔥 and Python lib

License

NotificationsYou must be signed in to change notification settings

automata/basquiat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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!

Setup

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.

Using

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/.

Studies

Random walk

A couple of random walkers with 100k steps.

Lines

Inspired by Joy Division'sUnknown Pleasure album cover.

Noise

Some experiments with uniform and Perlin noise.

About

Simple creative coding Mojo 🔥 and Python lib

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp