All that you need to get Ruby-Processing going is Ruby (1.8 or 1.9) and Java (1.5 or 1.6) — and your machine probably came with both of those baked-in. Then, naturally, you’ll need to get your hands on Ruby-Processing itself. It’s available as a Ruby Gem:

sudo gem install ruby-processing

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:

rp5 unpack samples
rp5 run samples/contributed/jwishy.rb

And voilà.

To download a large number of examples from the Learning Processing book, check out Learning Processing with Ruby, and download the examples.

Making Your Own

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. The generated my_sketch.rb will look like:

# My Sketch
class MySketch < Processing::App
  def setup
  end
  def draw
  end
end
MySketch.new :title => "My Sketch", :width => 800, :height => 600

Bare Sketches

Ruby-Processing also supports bare sketches, without any class definition (implicitly wrapped in a Processing::App), or without any method definitions (wrapped inside the ‘setup’ method). To create a bare sketch, do a rp5 create --bare my_sketch 800 600. You’ll receive this:

def setup
  size 800, 600
end
def draw
end

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.

All that you need to get Ruby-Processing going is Ruby (1.8 or 1.9) and Java (1.5 or 1.6) — and your machine probably came with both of those baked-in. Then, naturally, you’ll need to get your hands on Ruby-Processing itself. It’s available as a Ruby Gem:

sudo gem install ruby-processing

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:

rp5 unpack samples
rp5 run samples/contributed/jwishy.rb

And voilà.

To download a large number of examples from the Learning Processing book, check out Learning Processing with Ruby, and download the examples.

Making Your Own

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. The generated my_sketch.rb will look like:

# My Sketch
class MySketch < Processing::App
  def setup
  end
  def draw
  end
end
MySketch.new :title => "My Sketch", :width => 800, :height => 600

Bare Sketches

Ruby-Processing also supports bare sketches, without any class definition (implicitly wrapped in a Processing::App), or without any method definitions (wrapped inside the ‘setup’ method). To create a bare sketch, do a rp5 create --bare my_sketch 800 600. You’ll receive this:

def setup
  size 800, 600
end
def draw
end

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.

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。