-
Notifications
You must be signed in to change notification settings - Fork 89
Getting Started
Read platform requirements "here":https://github.com/jashkenas/ruby-processing/wiki/Platform-and-Environment Before you start you might wish to install jruby on your system see "here":http://www.jruby.org/ Building and installing from the cloned repo unix:-
git clone https://github.com/jashkenas/ruby-processing.git
cd ruby-processing
# optional step for bundler users
bundle install # can be used to tie ruby-processing to jruby, and installs build dependencies
rake # This builds, and tests the ruby-processing-2.3.1.gem (an external minitest is preferred)
jruby -S gem install ruby-processing-2.3.1.gem # to install locally may need sudo access
# or if not using an installed jruby (or if you have a clever way of managing gem hell)
gem install ruby-processing-2.3.1.gem # to install locally may need sudo access especially ubuntu
Windows user might prefer to use "github for windows":http://windows.github.com/ to clone repo, I'm not sure there is a rake-gui for windows, so some terminal work will be required.
Alternatively there is a "zipped source for latest release here.":https://github.com/jashkenas/ruby-processing/releases Simply unzip/untar the archive in your local directory and use rake as described previously.
Ruby-Processing provides you with the @rp5@ command, which is what you'll use to run all the Ruby-Processing commands. Try typing @rp5 --help@ to get a brief overview of the options. If you're ready to try out an example, then let's get started by unpacking the folder of samples so that you can examine and run them. Go to a folder where you'd like to store the samples, and type:
jruby -S rp5 unpack samples
jruby -S rp5 run samples/contributed/jwishy.rb
Or if not using an installed jruby
rp5 unpack samples
rp5 --nojruby run samples/contributed/jwishy.rb
Or if jruby is your default ruby, or you have smart ruby version control system
rp5 unpack samples
rp5 run samples/contributed/jwishy.rb
And voilà.
!http://s3.amazonaws.com/jashkenas/images/jwishy.png!
See also examples from the "Learning Processing":http://learningprocessing.com book, check out "Learning Processing with Ruby":http://github.com/jashkenas/learning-processing-with-ruby, and "download the examples":http://github.com/jashkenas/learning-processing-with-ruby/zipball/master (however many of the sketches are in need of updating for processing-2.0).
h2. Making Your Own
Since the latest release bare sketches are preferred, although class wrapped sketches are still supported. Because every sketch has a @setup@ method, called once at the start, and a @draw@ method, called continuously as it animates; Ruby-Processing includes a sketch creator to get you started on the right foot with the proper (minimal) boilerplate. Using @rp5 create my_sketch 800 600@, will generate a Processing::App that's 800 by 600 pixels in size, and just displays a blank window.
def setup
size 800, 600
end
def draw
end
h2. P3D sketches
@jruby -S rp5 create my_sketch --p3d 800 600@
def setup
size 800, 600, P3D
end
def draw
end
h2. Windows caveats
Gem install didn't seem to create environment variable %RP5_ROOT% upon which ruby-processing depends. Adding this environment variable to the path of the gem seemed to do the trick. If you're getting some errors where you don't know whats going on this might be the issue.