Code Monkey home page Code Monkey logo

ruby-processing's Introduction

Ruby-Processing

Gem Version

Is a ruby wrapper around the Processing code art framework, built using JRuby.

Processing provides a tidy API, with a bunch of handy methods you can call from Ruby-Processing. Here's a smattering:

alpha, arc, background, blend, blue, ellipse, frame_rate, hue, lerp, load_image, load_pixels, mouse_pressed, noise, rect, saturation, shape, smooth, text_align, translate, triangle...

Installation

Ideally you should install jruby, at the very least you will have at least ruby-1.9.3 installed. You should download and install vanilla processing-2.0.3 (MacOSX) or processing-2.1.0 (Windows, Linux) prior to installing this version of ruby-processing. You must also set the PROCESSING_ROOT in the .rp5rc yaml configuration file, the easiest way is by running the SetProcessingRoot.pde sketch in the processing ide.

Then install ruby-processing (from rubygems-org) in the usual way

gem install ruby-processing some systems eg Ubuntu may require sudo access

To install jruby-complete use our built in tool (relies on wget to download jruby-complete-1.7.10)

install_jruby_complete

If you haven't got wget just download jruby-complete-1.7.10 to the vendors folder (then run above tool)

The vendored jruby-complete-1.7.10 is only required for application export, and running certain sketches (eg shader sketches see wiki).

Documentation

See Wiki

See also FAQs, Contributing and Samples

Usage Example

rp5 run my_sketch.rb 

or if not using system jruby

rp5 --nojruby run my_sketch.rb

where a simple my_sketch.rb could look like this

def setup
  size 400, 400  
  fill 255
end

def draw
  background 0
  ellipse mouse_x, mouse_y, 100, 100
end

or a simple 3D sketch cube.rb

def setup
  size 640, 360, P3D 
  @xmag = 0
  @ymag = 0
  @new_xmag = 0
  @new_ymag = 0 
  fill 200, 50, 50
end

def draw    
  background 100    
  push_matrix    
  translate width/2, height/2, -30    
  @new_xmag = mouse_x.to_f / width * TWO_PI
  @new_ymag = mouse_y.to_f / height * TWO_PI    
  diff = @xmag - @new_xmag
  @xmag -= diff / 4 if diff.abs > 0.01    
  diff = @ymag - @new_ymag
  @ymag -= diff / 4 if diff.abs > 0.01    
  rotate_x(-@ymag) 
  rotate_y(-@xmag)    
  box 150, 150, 150        
  pop_matrix        
end

Supported Ruby Version

This library has been tested with the following ruby implementations

  • Ruby 1.9.3
  • Ruby 2.0.0
  • JRuby preferred (required to use rubygems in sketches)

License

What's new

New capabilities since processing-2.0 include ability to use OPENGL VBO (PShape) and GLSL shaders (PShader), to keep abreast of latest shader developments for processing check out the codeanticode blog. Some worked examples using new feature are included in the samples. The update to the latest jruby is also significant as the default is to run with ruby-1.9 support (or even use ruby-2.0 syntax with compat.version=2.0 in your .jrubyrc config), and there have been many performance improvements. Some performance improvements will not be available on the Mac as they require at least java-7+, and there is even more to come with java-8+ (adventurous Mac users can read more about Oracle java here ). More than 330 worked examples are included in the Samples, many of which are rubified version of the examples included with vanilla processing, and or the contributed libraries, additions are welcome.

ruby-processing's People

Contributors

arirubinstein avatar endymion avatar fjenett avatar grossbart avatar jandot avatar jashkenas avatar jdan avatar joannecheng avatar jurisgalang avatar martinstannard avatar maxhawkins avatar mchung avatar monkstone avatar murasesyuka avatar nicksieger avatar peterkrenn avatar rick avatar skade avatar yush avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.