Giter Site home page Giter Site logo

doersino / brachiosaurus Goto Github PK

View Code? Open in Web Editor NEW
8.0 3.0 0.0 616 KB

An incredibly basic turtle drawing tool I've built for making generative art with my BrachioGraph pen plotter.

License: MIT License

Python 100.00%
brachiograph pen-plotter turtle-graphics svg-generator svg python

brachiosaurus's Introduction

brachiosaurus ๐Ÿฆ•

An incredibly basic turtle drawing tool I've built for making generative art with my BrachioGraph pen plotter.

Setup

Build a BrachioGraph and set it up with a Raspberry Pi according to the instructions.

The Python 3 script brachiosaurus.py contained in this repository has no dependencies aside from the standard library. If you run it on a computer whose hostname is raspberrypi, it'll dynamically attempt to import brachiograph and draw the programmed pattern, otherwise it'll generate an SVG version (see above) instead and emit it on stdout.

The Raspberry Pi hostname (and the BrachioGraph configuration โ€“ the default probably won't be accurate for your build) are configurable at the top of brachiosaurus.py.

Deployment

Copy brachiosaurus.py to the directory on your Raspberry Pi in which you've installed the BrachioGraph software. With my setup, that's done like this:

scp ~/Dropbox/code/brachiosaurus/brachiosaurus.py [email protected]:/home/pi/BrachioGraph/

Usage

Place the code to generate the image you'd like to draw inside the main function.

Similar to how you'd use the default BrachioGraph software โ€“ on your Raspberry Pi, after boot, run sudo pigpiod to set up hardware servo timing. Then:

cd BrachioGraph
source bin/activate
python3 brachiosaurus.py

Alternatively, on your "development" machine where you haven't set up the BrachioGraph software, simply run

python3 brachiosaurus.py > ~/Desktop/preview.svg

and open preview.svg in a web browser or other SVG viewer of your choice. This allows for fast and easy development of a complicated drawing without having to actually plot it until it's right, although I advise not previewing simpler ones โ€“ you never know which happy accidents you'd miss.

You want to keep library and drawing code separate?

Not a bad idea at all! Create a file mydrawing.py next to brachiosaurus.py:

import brachiosaurus as bs  # heartbreakingly, python won't accept ๐Ÿฆ• as an alias

c = bs.Canvas()

# turtle drawing commands go here

plotter = bs.AutoPlotter().from_canvas(c)
#plotter = bs.AutoPlotter().from_file("test-patterns/accuracy.json")
plotter.emit()

Then, as above, deploy this new file to your Raspberry Pi:

scp ~/Dropbox/code/brachiosaurus/mydrawing.py [email protected]:/home/pi/BrachioGraph/

And run it:

python3 mydrawing.py.

Or run it without deployment:

python3 ~/Dropbox/code/brachiosaurus/mydrawing.py > ~/Desktop/preview.svg

You're looking for some examples?

Look no further than examples.py โ€“ which has the same structure as the mydrawing.py file outlined above and can be deployed and run in the same manner โ€“ where I've been collecting the code of some drawings I've made myself.

Alternatively, you can easily create your own examples using UJI, a generative art tool of my own design โ€“ it's able to export drawings in the JSON format supported by the AutoPlotter().from_file() function.

You've got a different plotter?

The code is intentionally kept simple and extendible.

  • Drawings are represented as lists of lines,
  • lines are lists of points, and
  • points are 2-ary lists of x and y coordinates.

If your plotter can be driven via Python and you're able to implement a function that translates this representation into whatever representation your plotter expects (see RealPlotter.emit and FakePlotter.emit), you should be golden. (Feel free to send a pull request!)

Related Work

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.