Using Proscene Library
Here is an example sketch by Jean Pierre Charalambos, that has been refactored for JRubyArt. Install the proscene library from the processing-3.2.1 ide.
basic_use.rb
# Basic Use.
# by Jean Pierre Charalambos.
#
# This example illustrates a direct approach to use proscene by Scene proper
# instantiation.
#
# Press 'h' to display the key shortcuts and mouse bindings in the console.
load_library :proscene
include_package 'remixlab.proscene'
attr_reader :scene
def settings
size(640, 360, P3D)
end
def setup
sketch_title 'Basic Use'
# We instantiate the Scene class
@scene = Scene.new(self)
# when damping friction = 0 -> spin
scene.eye_frame.set_damping(0)
# puts format('spinning sens: %.3f', scene.eye_frame.spinningSensitivity)
end
def draw
background(0)
fill(204, 102, 0, 150)
scene.draw_torus_solenoid
end
def key_pressed
damping = scene.eye_frame.damping.zero? ? 0.5 : 0
scene.eye_frame.set_damping(damping)
puts format('Camera damping friction now is %.1f', damping)
end
Here is the alternative use example using inheritance
alternative_use.rb
# Alternative Use.
# by Jean Pierre Charalambos.
#
# This example illustrates how to use proscene through inheritance.
#
# Press 'h' to display the key shortcuts and mouse bindings in the console.
load_library :proscene
include_package 'remixlab.proscene'
attr_reader :scene
def settings
size(640, 360, P3D)
end
def setup
sketch_title 'Alternative Use'
# We instantiate our MyScene class defined below
@scene = MyScene.new(self)
# scene.init
end
# Make sure to define the draw method, even if it's empty.
def draw
end
class MyScene < Scene
# We need to call super to instantiate the base class
def initialize(p)
super
end
# Initialization stuff could have also been performed at
# setup, once after the Scene object have been instantiated
def init
set_grid_visual_hint(false)
end
#Define here what is actually going to be drawn.
def proscenium
background(0)
fill(204, 102, 0, 150)
draw_torus_solenoid
end
end