Skatolo a gui for JRubyArt and propane
Skatolo is a replacement for controlP5 in JRubyArt and propane. To install:-
gem install skatolo
The usage is really simple, you need to require 'skatolo'
then add the magic :create_method
by including the EventMethod as below, in the case of buttons
provide an appropriate method. Slider values can be read as method name + _value
EventMethod module
module EventMethod
def create_method(name, &block)
self.class.send(:define_method, name, &block)
end
end
Button Sketch
require 'skatolo'
# In this simple sketch we attach two buttons to skatolo in the regular way,
# named buttons 'press_me' and 'reset' thanks to some fancy metaprogramming
# we can create methods :press_me and :reset for the buttons
include EventMethod
attr_reader :skatolo, :back_color
def settings
size(400, 300)
end
def setup
sketch_title 'Skatolo Buttons'
create_gui
skatolo.update # this step is important
@back_color = color(200, 0, 200)
end
def draw
background(back_color)
end
def reset
@back_color = color(200, 0, 200)
end
def press_me
@back_color = color(200, 0, 0)
end
def create_gui
@skatolo = Skatolo.new(self)
skatolo.add_button('press_me')
.set_position(10, 10)
.set_size(50, 20)
.set_label('Press Me!')
skatolo.add_button('reset')
.set_position(10, 40)
.set_size(50, 20)
.set_label('Reset!')
end
Slider Sketch
require 'skatolo'
# In this simple sketch we attach a slider to skatolo in the regular way, with
# a named slider 'background_color' and thanks to some fancy metaprogramming
# we can read the result from background_color_value
include EventMethod
attr_reader :skatolo
def settings
size(400, 300)
end
def setup
sketch_title 'Skatolo Slider'
create_gui
skatolo.update # this step is important
end
def draw
background(background_color_value)
end
def create_gui
@skatolo = Skatolo.new(self)
skatolo.add_slider('background_color')
.set_position(10, 10)
.set_size(150, 20)
.set_range(80, 255)
.set_value(180)
.set_label('Background color')
end
Skatolo was developed by Jeremy Lavoile and is a clone of controlP5 by Andreas Schlegel