Experiments with ruby-processing (processing-2.2.1) and JRubyArt for processing-3.0

Thursday, 17 December 2009

Using the Anar+ library in ruby-processing

First you need to put both opengl and anar libraries in eponymous folders (same name) and them both in an outer folder library, then your sketch can load the libraries 'easy-peasy'. If you are not on linux, you do not need not run full screen but you should because its great. This sketch apart from the full_screen is virtually a straight translation of a java processing example from http://anar.ch. NB Use scroll wheel to zoom or equivalent gizmo.

load_libraries 'anar', 'opengl'
import "anar" if library_loaded? "anar"
import "processing.opengl" if library_loaded? "opengl"

attr_accessor :my_obj

def setup()
  library_loaded?(:opengl) ? setup_opengl : fail_opengl



def setup_opengl
  render_mode OPENGL
  hint ENABLE_OPENGL_4X_SMOOTH #optional

def init_form()

  #Create a new Line
  pts = Pts.new

  #Create a Face
  f = Star.new(50,100,5)
  #Extrude the face along the Line
  @my_obj = Extrude.new(f,pts)

def draw()

def fail_opengl
  abort "!!!You absolutely need opengl for this sketch!!!"

#Toggle the display of the sliders
def keyPressed()

Original author Guillaume LaBelle (I think?), sliders are bit tiny and fall off the end but functionality is superb (there might have been sound as there is some complaint about lack of promidi, however nothing happened for me when I loaded the appropriate libraries).

1 comment:

  1. Yes, ProMidi is optional, it's only used to control the sliders through Midi (when both library and a midi input is found). The sliders are very basic, they meant to be redefined by the user, we(*) thought it may be useful to provide predefined sliders lists. This is the same for the camera, it's very elementary. You could turn this off by using (in setup()):
    Anar.defaultScene= false;
    Then, you could use your favorite camera.

    I'm glad to see your example, and your work as well.

    (*) We is me and Julien Nembrini



Blog Archive

About Me

My photo
I have developed JRubyArt and propane new versions of ruby-processing for JRuby- and processing-3.2.2