Enough is enough
While coding the umpteenth super low-level function, I decided to revisit processing, and take a longer, harder look at how I am running things. Turns out, the processing.py from the command line page was very helpfull. I will use their mouse_follow.py
example:
def setup():
size(400, 400)
def draw():
background(255)
fill(0)
ellipse(mouseX, mouseY, 50, 50)
First of all, download the Processing standalone version, in my case for osx
My first attempt, running mouse_follow.py
on my old MPB threw an error Unsupported major.minor version 52.0
which meant I had to upgrade my java. Great… In my opinion, Oracle shouldn’t b relied on for proper install. Instead I used Homebrew
brew update
brew cask install java
Note that Java 11 (the default now) will spew some “illegal reflective action” warning and crash for me. So I went for
brew tap caskroom/versions
brew cask install java8
Which works fine for the mouse example.
What next ?
Running Scripts
If you plan on loading significant data into processing (which you will, eventually) passing some parameters (into a ~/.bashrc alias for example) is probably a good idea. Something like:
java -Xms256m -Xmx1024m -jar processing-py.jar myscript.py
For workflow purposes, we should have a way to run scripts.
Pycharms
Vim is love, but Pycharms is a solid IDE. Introspection while debugging, for example, can be very useful. My “ghetto” solution is to create a run_pgm.py
of sort at the root:
import os
print(os.getcwd())
os.system("java -Xms256m -Xmx1024m -jar processing-py.jar mouse_follow.py")
You can go fancier and pass the name of your actual script, but I find this setup does the job: run it once, then do edits on your actual script and hit your ctrl-r
equivalent command.
One downside is that script boot time is fairly long.
Vim
With most generative art being relatively simple project structures, Vim probably is good enough as an IDE. We still need a short command to launch scripts.
First, create a shortcut for the java launch. Something like ~/.proc_alias
:
shopt -s expand_aliases
alias xx ='java -Xms256m -Xmx1024m -jar processing-py.jar'
Use a short, but not taken (pr
e.g.) alias, and allow explicit expansion of alias (see this for reference).
Then edit your ~/.vimrc
to load the alias:
let $BASH_ENV = "~/.proc_alias"
Now we can run the script from vim, using %
to the current file reference: :!xx %
On my beat-up old MBP, the launch time is significantly lower.
Post-Scriptum
processing.py has a tweak for external files (like fonts or images, for example) and will look into data/ then at the root. So create a data/ folder:
mkdir data
This way, fonts, images or whatnots which cannot be referenced with full path (no os.path
, no glob.glob
) but you placed there will be accessable for loading (no path, just file name).
Am I using it ? Limitations ?
At the moment, no. The main issue with that setup is that (as far as I know) processing’s jython cannot run non-pure python. No Numpy, no Scipy which is kind of a bummer. I’m still having fun with those, and therefore still messing with pycairo. On the other hand, processing makes exporting standalone app very easy, and potentially deployable for interactive experience, for example. For these, accessing the higher-order functions of processing is definitely an advantage.
Suggested Music
Lui Mafuta plays an exotic sounding great set, riddled with some German for bonus points. Tres cool…