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

Wednesday 19 December 2012

Exporting cf3ruby directly to 'large' pdf

With the processing pdf export library it is easy to export processing sketches to pdf. This is also true for ruby-processing sketches, including those using the cf3ruby library see example below:-
# levy.rb ruby-processing NB: :alpha is now implemented ruby-processing
require 'cf3', 'pdf'
include_package 'processing.pdf'

def setup_the_levy
  @levy = ContextFree.define do
    shape :start do
      levy brightness: 0.9
    end
    shape :levy do
      square alpha: 0.1
     split do
        levy  size: 1/Math.sqrt(2), rotation: -45, x: 0.5, brightness: 0.9
        rewind
        levy  size: 1/Math.sqrt(2), rotation: 45, x: 0.5, brightness: 0.9
     end
    end
  end
end


def setup
  size 2000, 2000, PDF, "levy.pdf"
  setup_the_levy
  smooth
  draw_it
end


def draw
  exit
end


def draw_it
  background 255
  @levy.render :start, size: 250,  stop_size: 2,
        start_x: width/4, start_y: height/2
end

No comments:

Post a Comment

Followers

Blog Archive

About Me

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