Getting Started With propane (stolen from Ben Lewis)

If you love to code because it is a creative process, then you should give propane a try because it can be used to create music, art, animations, videos and much more. Also since it is based on the latest Processing you can access a vast range of libraries to make the difficult things easier.

What Is Processing?

Processing is a simple language, based on Java, that you can use to create digital graphics. It’s easy to learn, fun to use, and has an amazing online community comprised of programmers, visual artists, musicians, and interdisciplinary artists of all kinds.

Processing was built by Casey Reas and Benjamin Fry, two protegés of interdisciplinary digital art guru John Maeda at the MIT Media Lab.

Since the project began in 2001, it’s been helping teach people to program in a visual art context using a simplified version of Java. It comes packaged as an IDE that can be downloaded and used to create and save digital art “sketches”.

In 2009, Jeremy Ashkenas (aka jashkenas, creator of Backbone.JS, Underscore.JS, and Coffeescript), published the original ruby-processing gem. It wraps Processing in a shim that makes it even easier to get started if you know Ruby. It has been since updated to use processing-2.2.1 by Martin Prout (final version using jruby-1.7.27 corresponding to ruby-1.9.3 syntax), NB: no more releases are expected, and ruby-processing is not compatible with processing-3.0+. In 2016, Martin Prout (aka monkstone) published the propane gem, loosely based on the original ruby-processing, but updated to use processing-3.3 and jruby-9.1.7.0+ (ruby-2.3 syntax)

Why propane?

You can dabble with the latest processing framework (in ruby) without even needing to install vanilla processing (and its embded jdk).

Additionally, you don’t have to declare types, voids, or understand the differences between floats and ints to get started, as you do in pure Processing.

Although there are some drawbacks to using the Ruby version Processing (slower start up time, and sometimes performance), having Ruby’s API available to translate your ideas into sketches more than makes up for them.

Why was ruby-processing not updated to use processing-3.0+? The major changes between processing-2.2.1 and processing-3.0 are not backward compatible. Furthermore since propane was designed to use jruby-9.0.0.0 from the outset, it makes use of the more literate ruby-2.2 syntax (although the original ruby-processing will run with jruby-9.1.13.0, the examples and the ruby-processing library are all based on ruby-1.9.3 syntax).

Setup

Setting propane is dead easy. The propane gem relies on jruby and arc_ball.gem, you don’t need rvm or rvm for this don’t let anyone persuade that you do.

Java

You can use either Oracle or openjdk, but it must be jdk8, as there are unresolved issues with both JRuby and processing with jdk9.

Install homebrew, wget, java (1.8.0_131+)

In case you have issues, it has been reported to be useful to set the JAVA_HOME and to add the path to java to your PATH

JRuby

Unlike JRubyArt and ruby-processing it is not possible to run propane without a system install of jruby. It is highly recommended that you create a symbolic link to /usr/bin/jruby, it is the easiest way to ensure that jruby is on you PATH and you can then make sketches executable with #!/usr/bin/env jruby (and chmod +x). Further you will be able to run sketches from atom using the script plugin (without needing to start atom from the command-line to pick up environmental variables).

propane

jgem install propane # or `jruby -S gem`, use rvm at your own risk...

Install Samples

propane --install Samples

Install Sound library

propane --install Sound

Install Video library the past but stable?

propane --install Video

Install GLVideo library the future but unstable

propane --install glvideo
# experimental, expected to work on Raspberry-Pi debian-linux and MacOS

On MacOS the video library uses the somewhat outdated gstreamer-0.1.0 under the hood. Please change the name of the video binary folder from macosx64 to macosx I have reported this to processing.org but they are not changing it and anyway the video library is slated to be replaced by glvideo, that supports gstreamer-1.0 (and hence hardware acceleration).

Running examples

To run a bunch of the samples as a demo:-

cd ~/propane_samples
rake # autoruns a bunch of files as a demo
cd ~/propane_samples/contributed # for example
rake # autoruns files in contributed folder
jruby jwishy.rb # run the JWishy sketch, using an installed jruby
cd ~/propane_samples/processing_app/topics/shaders
rake # autoruns shader sketches
jruby monjori.rb # run single shader sketch, since propane-1.0

Creating your own sketch

All we ask is that you obey the ruby filename convention (ie snakecase) and we can create a template sketch for you as follows:-

propane --create fred_sketch 200 200 # creates a propane sketch fred_sketch.rb (see below)
vim fred_sketch.rb
:!jruby % # from vim runs the sketch

other editors are available

# frozen_string_literal: true
require 'propane'

class FredSketch
  def setup
  sketch_title 'Fred Sketch'
  end

  def draw

  end

  def settings
  size 200, 200
  # smooth # here
  end
end

FredSketch.new

Running examples

To run a bunch of the samples as a demo:-

cd ~/propane_samples
rake # autoruns a bunch of files as a demo
cd ~/propane_samples/contributed # for example
rake # autoruns files in contributed folder
jruby jwishy.rb # run the JWishy sketch, using an installed jruby
cd ~/propane_samples/processing_app/topics/shaders
rake # autoruns shader sketches
jruby monjori.rb # run single shader sketch, since propane-1.0

Creating your own sketch

All we ask is that you obey the ruby filename convention (ie snakecase) and we can create a template sketch for you as follows:-

propane --create fred_sketch 200 200 # creates a propane sketch fred_sketch.rb (see below)
vim fred_sketch.rb
:!jruby % # from vim runs the sketch

other editors are available

# frozen_string_literal: true
require 'propane'

class FredSketch
  def setup
  sketch_title 'Fred Sketch'
  end

  def draw

  end

  def settings
  size 200, 200
  # smooth # here
  end
end

FredSketch.new

PS: propane -c fred also works with a default size 0

Read more about using the processing api here