Coder Social home page Coder Social logo

shoebot / shoebot Goto Github PK

View Code? Open in Web Editor NEW
120.0 120.0 25.0 22.5 MB

Easy vector graphics with Python

Home Page: http://shoebot.net

License: GNU General Public License v3.0

Makefile 0.17% Shell 0.72% Python 99.04% Cython 0.07%
computer-graphics creative-coding gedit-plugin graphics live-coding nodebox python

shoebot's Introduction

Shoebot

Shoebot is a creative coding environment designed for making vector graphics and animations with Python. It's geared towards playful graphic exploration, creating SVG images for pen plotters, and is a great tool for automated/headless image generation.

Build Status Matrix channel

Shoebot takes a Python script describing a drawing process, and outputs a graphic in vector (SVG, PDF, PostScript) and bitmap formats (PNG). Animations can be easily created and output to video files (mp4). Scripts can describe their own GUIs for controlling variables interactively. Shoebot can also be run from the commandline and used as a Python module inside other Python scripts.

Shoebot is a port/rewrite of Nodebox 1, which is derived from DrawBot. The playful coding philosophy of Shoes also inspired its development. Thus, "Shoebot".

Documentation

The Shoebot Manual can be found at docs.shoebot.net.

Getting help

Installation is the trickiest aspect of Shoebot. If you run into trouble following the install steps, create a new issue and paste the output of the following commands:

python3 setup.py diagnose
python3 setup.py test

This will help us diagnose common issues more quickly.

Links

License

Copyright © 2007-2021 The Shoebot authors (Stuart Axon, Dave Crossland, Francesco Fantoni, Ricardo Lafuente, Sebastian Oliva)

Originally developed by Ricardo Lafuente with the support of the Piet Zwart Institute, Rotterdam.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

shoebot's People

Contributors

aoloe avatar artfwo avatar elisadcg avatar gaborpapp avatar hvfrancesco avatar pedropintosilva avatar rlafuente avatar speters33w avatar stuaxo avatar tian2992 avatar xuv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shoebot's Issues

Command line option for dynamic variables

Dynamic variables defined with var() are pretty useful for playing and experimenting visually.

They could be even more powerful if there was a way to specify their values when the script is run. I think a JSON representation could work here:

sbot --vars "{'width': 360, 'height': 240}"

An immediate use I can see for this is batch output -- using a script as a template for multiple output files.

Gedit plugin needs updating for Gedit 3

(imported from the old bug tracker, original report by @stuaxo)

Gedit 3 has a different plugin structure so the old one doesn't work.

As gedit 3.x uses gtk3 and shoebot is still on gtk2, the new plugin might need to
run shoebot as a subprocess.

OpenCV lib is broken

(imported from the old tracker)

The OpenCV library is not working. I had to remove it from the build list in order to be able to create the Debian packages.

@hvfrancesco:
I guess it's going to be worth waiting until the new python opencv interface gets into Ubuntu before revamping sbopencv library
http://opencv.willowgarage.com/documentation/python/introduction.html

@stuaxo:
RPythonic has opencv bindings written in ctypes
http://code.google.com/p/rpythonic/
Perhaps that could help ?

Gedit plugin - python env chooser

The GEdit plugin should have an option to choose the python env...

The default options would probably be:

System python, any virtualenvs in ~/.virtualenvs that have sbot installed.

It might be useful to have this in a submenu - along with a config option to set the default env.

Render examples in documentation

It would be a huge step towards good docs if we could easily render example scripts in the documentation.

The graphviz extension (docs, code) in the Sphinx source looks like something that we can bend to run Shoebot scripts. The Shoebot directive would be a lot simpler than this one.

Missing Rect, Oval and Ellipse

Returning normal paths might be OK here?

Need to find examples that use them.. possibly just returning NotImplementedError might be enough.

Add --verbose option and hide internal part of errors by default

if I make an erronious script like

rect(40, 40, 40)

I get an error that includes info internal to shoebot ... by default the user should just get the script error, unless they specify verbose on the commandline:

Example current output

Traceback (most recent call last):
  File "/home/stu/.virtualenvs/shoebot/bin/sbot", line 146, in <module>
    args = args.args)
  File "/home/stu/.virtualenvs/shoebot/local/lib/python2.7/site-packages/shoebot/sbot.py", line 86, in run
    bot.sb_run(src, iterations, run_forever = window if close_window == False else False, frame_limiter = window)
  File "/home/stu/.virtualenvs/shoebot/local/lib/python2.7/site-packages/shoebot/grammar/grammar.py", line 146, in sb_run
    self._exec_frame(source_or_code, limit = frame_limiter)
  File "/home/stu/.virtualenvs/shoebot/local/lib/python2.7/site-packages/shoebot/grammar/grammar.py", line 98, in _exec_frame
    exec source_or_code in namespace
  File "shoebot_code", line 1, in <module>
TypeError: rect() takes at least 5 arguments (4 given)

Desired output (without --verbose) might look something like this..

Traceback (most recent call last):
  File "shoebot_code", line 1, in <module>
TypeError: rect() takes at least 5 arguments (4 given)

Control animation from the command line

(imported from the old tracker, original report by @stuaxo)

It would be useful to be able to control animation from the command line, starting frame, end frame, iteration - this could be done by using the slice operator, something like:

# play frames 0 to 10, jumping two frames each time
frames=0:10:2

# play frames from 0 to 10
frames=2:10

# play to frame ten
frames=10

Provide setup scripts..

Getting dependencies installed and setting up e.g. a virtualenv is a little fiddly, we should supply scripts for popular OSs.

Replace rectMode/pathMode with origin param

examples:

Constants can be passed
TOP
TOPLEFT
TOPRIGHT
CENTER
BOTTOMLEFT
BOTTOMRIGHT

Note - it could be desirable to use the J2Me style:

TOP | LEFT

rect(40, 40, origin=CENTER)

Along with a command

pathorigin(CENTER) to set the default .. rectMode and the pathMode params would be deprecated.

Port to gtk3

Gtk2 is deprecated, shoebot needs porting to Gtk3.

Locate code for all missing plugins [emacs, scribus, inkscape]

There's evidence around that there were plugins for emacs, scribus and inkscape.

Once we find the old code then porting to the new architecture shouldn't be hard.

To make sure they don't get lost it might be worth keeping the code under the extensions folder (if that means it's still possible to do stuff like publish to pypi).

emacs
http://code.goto10.org/projects/shoebot/ticket/12

Changed 4 years ago by rlafuente

I have absolutely zero experience with Emacs, so i'd encourage anyone with any kind of knowledge here to shed some light on this.

Changed 4 years ago by pangelo

type changed from defect to enhancement
I'd like to take a stab at this.

I've already made a skeleton implementation: http://www.bitbucket.org/pangelo/shoebot-emacs/

Changed 4 years ago by rlafuente

owner changed from rlafuente to pangelo
milestone changed from 0.2 to 0.2.1
wowies, if your implementation is working we'd totally need to have it available. Probably we'd need either a 'shoebot-emacs' package, or a big 'shoebot-plugins' package, i'm not sure what would be the best approach...

scribus
inkscape

var() for colors

Would be really nice to have a color picker widget... for editing bots it would be even more useful.

Snapshots should be easier to make

@rlafuente:
One very useful feature from previous versions of Shoebot was the ability of
creating a snapshot of the current canvas state into a file, anywhere in the script.

This feature seems to be absent from the current version (inherited from the -dq
branch), but I think I managed to replicate it here:

import shoebot
from shoebot.core import CairoCanvas, CairoImageSink, NodeBot
outputfile = 'output.svg'
sink = CairoImageSink(outputfile, "svg", multifile = False)
canvas = CairoCanvas(sink, enable_cairo_queue=True)
bot = shoebot.core.NodeBot(canvas)
bot.size(150,150)
bot.fill(1,0,0)
bot.rect(10,10,100,100)
bot._canvas.flush(frame=0)
bot.fill(0,0.5,0)
bot.rect(30,30,30,30)
sink.filename = 'output2.svg'
bot._canvas.flush(frame=0)

(thanks to @tian2992 and @codingisacopingstrategy for pointing the way)

Could we map a snapshot() function that replicates the procedure above? I
haven't touched the code for a long time and so am still getting acquainted with
the -dq way of doing things, so it won't be a while until I have a clue as how
to achieve this.

@codingisacopingstrategy:
Yes that’s a great idea. Maybe good to make a class that subclasses the nodebox
bot which adds all the methods that are useful when embedding, taking care of
the necessary imports etc

Oh and I have a feature request for this :) I’d like a method to not save to
disk, but to output the snapshot into a string, or at least a file object—in a
web interface, for example, writing the file to disk adds a layer of complexity:
I just want to return the data as an HTTP response.

@stuaxo:
This is definitely a bug.

snapshot() should be able to take a cairo surface or context and render to that
(although not sure if this is working at the moment).

The code you've submitted is a good test for this btw.

Implement shadow()

Could have some concept of post rendering effects, this would be one.

Other possibilities like blur() come to mind.

Notes on an Android port

(imported from the old tracker)

@hvfrancesco:

Some very early, lazy and useless notes and suggestions about a possible port of shoebot to android.

With the development of the scripting layer for android going on ( http://code.google.com/p/android-scripting/ ) that brings a functional python environment, I started to figure out whether it is going to be possible someday to have shoebot working on google's mobile os. Actually I can't imagine no real use or need, let's say it's just for fun ;)

obviously cairo has not been ported to android, and probably never will (way too heavy and complex), and as shoebot is cairo based, a port would probably require the cairo canvas to be replaced by something else.

It seems android uses skia ( http://code.google.com/p/skia/ ) as low level library for 2D graphics, it is open source and I think it could replicate the basic functions of cairo, but skia api is not even exposed through NDK and, more important, at present it has no python bindings, though it seems it is in their roadmap. I suppose a lot of things would be rather hard to re-implement with skia
(e.g. fonts, images, etc.)

Another option I thought of could be openvg ( http://www.khronos.org/openvg/ ). The most complete open source implementation I know of is ShivaVG (http://sourceforge.net/projects/shivavg/). It's built on top of OpenGL, and a port to android, though not yet existing, could be done using OpenGL ES, and therefore being hardware accelerated, that's not bad. I tried an attempt of porting it using android NDK, but the lack in GLES of some GL attributes implies patching the code and rewriting parts of it in order to use OpenGL ES, and obviously it's a task far too complex for me.

There is a commercial openvg implementation called Amanith (http://www.amanith.org/project.html). which has already an experimental port to android (http://comments.gmane.org/gmane.comp.handhelds.android.ndk/3657) that I was able to run as simple test on my phone (but as I said it is commercial). The nice aspect is that it already exists a project that provides python bindings for both ShivaVG and Amanith vg (http://code.google.com/p/pyopenvg/) though I must admit I have not tested it yet.

I'm sure there are other smarter or simpler possibilities for replacing cairo on android that I didn't think of.

All of the shoebot gui of course would need a rewrite as well, as of course there won't be a gtk environment, but simple gui with python is already possible on android, so I suppose that as long as the scripting layer is further developed, more complex python programs can really be a possibility on android.

Other non-pure-python modules can be ported to android already (PIL maybe?) but I must admit it's not a trivial task at all.

@tian2992:
I think an easier way would it be to use
http://organisms.be/NodeBox_for_OpenGL as a base

ellipse doesn't work with CENTER mode.

Had a look into this and it's because drawing ellipses draws a tiny ellipse, but using scaling.

When BezierPath tries to calculate _bounds it only sees the smaller size.

The solution would the to update the bounding size every time something is added to a path instead of the current solution.

test:

# The Circle + Square should always be in the same place, but in CORNER mode it is incorrect.
# TOGGLE BETWEEN MODES BY PRESSING '1' or '2'

mode = CORNER

def draw():
 global mode
 translate(WIDTH / 2, HEIGHT / 2)
 if key == '1':
     mode = CENTER
 elif key == '2':
     mode = CORNER

 transform(mode)
 rotate(FRAME)

 fill(1,1,0)
 circle(0, 0, 100)

 fill(1,0,0)
 rect(0, 0, 100, 100)

 fill(0, 1, 0)
 p = BezierPath()
 p.rect(0, 0, 100, 100)
 p.draw()

 fill(0)
 reset()
 text(mode, 100, 100)

option for automatically opening varwindow or socketserver if var() is specified [goto10/75]

option for automatically opening varwindow or socketserver if var() is specified

[Imported from http://code.goto10.org/projects/shoebot/ticket/75 ]

Reported by: rlafuente Owned by: rlafuente
Priority: minor Milestone: 0.3
Component: shoebot Keywords: config varwindow socketserver
Cc:
Description

this would be desirable once we get our ConfigParser? going.

currently, one has to check the varwindow/socketserver options on the IDE or commandline. It's probably not a bug, since when you're specifying live variables through var(), you might want to just have the socketserver, the varwindow or both (or in rare cases, such as test scripts, none).

Saving as SVG through the GTK window outputs a blank image

(original comments by @stuaxo)

Outputting an SVG through the commandline works fine, though. A workaround for now is to make your bot animated (have a draw function)

This only happens on non animated bots. We have to rethink the implementation of save if we want to avoid rerunning the script (and possibly changing the output).

Render implementation probably needs a way to render the last frame to a target.

Add stdout view to the Gedit plugin, retire shoebot-ide

(imported from the old tracker)

The old shoebot-ide is woefully outdated, and its functionality was implemented in the Gedit plugin. The plugin does away with reinventing the wheel at implementing yet another GtkSourceView-based IDE.

However, one major feature is missing from the plugin -- seeing standard output on the editor, possibly on the bottom pane (where the Python console is). The ability to see the output of print statements is very important for those beginning with Shoebot. Right now, the only way to see this output is to run Gedit from the command line, which is not at all optimal.

I haven't touched the Gedit code for months and only use the command line interface, so it might take some time for me to get a closer look at this. It would be great if someone could take a stab at it. The plugin only needs another simple text display widget to show standard output. It's rather easy to hack on the plugin code.

See http://live.gnome.org/Gedit/PythonPluginHowTo for all the info needed to implement this easily. It's all there -- just needs someone to code it :-)

This would be the final step to finally do away with the shoebot-ide cruft!

Set var() values through the command line

(imported from the old tracker)

It would be good to be able to specify var() variable values through the commandline.

Maybe through a dict specified in the sbot command, or find a way to pipe data into the command via stdin.

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.