Skip to content

Commit a3c96a5

Browse files
committed
add readme
1 parent 3b144ef commit a3c96a5

File tree

8 files changed

+175
-95
lines changed

8 files changed

+175
-95
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# skatolo
2+
3+
### Skatolo is a GUI library for Processing, forked from [ControlP5](https://github.com/sojamo/controlp5)
4+
See repo on [github](https://github.com/Rea-lity-Tech/Skatolo) to run these examples you require gem version 1.1.4+ (if only 1.1.3 version is available from rubygems then clone repo to build)
5+
6+
### About
7+
8+
The skatolo java library was developed for an [advanced use of ControlP5](https://github.com/poqudrof/PapARt), it is not as convenient to use. It is a part of a research and development project involving multi-touch, augmented reality and Ruby. However it has also been adapted to work easily with JRubyArt (and hence propane). The skatolo library is developed by [Jeremy Laviole](http://jeremy.laviole.name/).
9+
10+
#### Sliders
11+
12+
If you name slider 'fred' then you will be able access the value as `fred_value`
13+
14+
#### Buttons
15+
16+
If you name the button 'my_method' you will be able create a method `:my_method` that gets called when button is pressed.
17+
18+
### Usage
19+
20+
Sketches need to `require 'skatolo'`, and `include EventMethod`, otherwise usage is similar to ControlP5 except `Skatolo.new(self)` instead of `ControlP5.new(self)`
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Simple demo Rakefile to autorun samples in current directory
2+
3+
SAMPLES_DIR = './'
4+
5+
desc 'run demo'
6+
task default: [:demo]
7+
8+
desc 'demo'
9+
task :demo do
10+
samples_list.shuffle.each { |sample| run_sample sample }
11+
end
12+
13+
def samples_list
14+
files = []
15+
Dir.chdir(SAMPLES_DIR)
16+
Dir.glob('*.rb').each do |file|
17+
files << File.join(SAMPLES_DIR, file)
18+
end
19+
return files
20+
end
21+
22+
def run_sample(sample_name)
23+
puts "Running #{sample_name}...quit to run next sample"
24+
open("|jruby #{sample_name}", 'r') do |io|
25+
while l = io.gets
26+
puts(l.chop)
27+
end
28+
end
29+
end

external_library/gem/skatolo/button_group.rb

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
require 'propane'
33
require 'skatolo'
44
# In this simple sketch we attach three buttons to skatolo in the regular way,
5-
# named buttons 'press_me' and 'reset' thanks to some fancy metaprogramming
6-
# we can create methods :red_color, :green_color and :blue_color for the buttons
7-
class SkatoloButtonGroup < Propane::App
8-
5+
# and group them, then add the group to the accordion widget
6+
# named buttons 'red_color' ... thanks to some fancy metaprogramming
7+
# we can create methods :red_color, :green_color and :blue_color buttons
8+
class ButtonGroup < Propane::App
99
include EventMethod
10+
11+
COLOR = %w[Red Green Blue].freeze
12+
1013
attr_reader :skatolo, :back_color
1114

1215
def settings
@@ -39,26 +42,18 @@ def blue_color
3942
def create_gui
4043
@skatolo = Skatolo.new(self)
4144
color_group = skatolo.add_group('colors')
42-
skatolo.add_button('red_color')
43-
.set_group(color_group)
44-
.set_position(0, 10)
45-
.set_size(50, 20)
46-
.set_label('Red')
47-
skatolo.add_button('green_color')
48-
.set_group(color_group)
49-
.set_position(0, 30)
50-
.set_size(50, 20)
51-
.set_label('Green')
52-
skatolo.add_button('blue_color')
53-
.set_group(color_group)
54-
.set_position(0, 50)
55-
.set_size(50, 20)
56-
.set_label('Blue')
45+
%w[red_color green_color blue_color].freeze.each_with_index do |col, index|
46+
skatolo.add_button(col)
47+
.set_group(color_group)
48+
.set_position(0, 10 + index * 20)
49+
.set_size(50, 20)
50+
.set_label(COLOR[index])
51+
end
5752
skatolo.add_accordion('acc')
5853
.set_position(20, 10)
5954
.set_size(50, 20)
6055
.add_item(color_group)
6156
end
6257
end
6358

64-
SkatoloButtonGroup.new
59+
ButtonGroup.new

external_library/gem/skatolo/buttons.rb

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,21 @@
44
# In this simple sketch we attach two buttons to skatolo in the regular way,
55
# named buttons 'press_me' and 'reset' thanks to some fancy metaprogramming
66
# we can create methods :press_me and :reset for the buttons
7-
class SkatoloButtons < Propane::App
7+
8+
class ButtonDemo < Propane::App
89
include EventMethod
10+
911
attr_reader :skatolo, :back_color
1012

1113
def settings
1214
size(400, 300)
1315
end
1416

1517
def setup
16-
sketch_title 'Skatolo Buttons on Propane'
17-
@skatolo = Skatolo.new(self)
18-
skatolo.add_button('press_me')
19-
.set_position(10, 10)
20-
.set_size(50, 20)
21-
.set_label('Press Me!')
22-
skatolo.add_button('reset')
23-
.set_position(10, 40)
24-
.set_size(50, 20)
25-
.set_label('Reset!')
26-
skatolo.update # this step is important
27-
@back_color = color(200, 0, 200)
18+
sketch_title 'Skatolo Buttons'
19+
create_gui
20+
skatolo.update # this step is important
21+
@back_color = color(200, 0, 200)
2822
end
2923

3024
def draw
@@ -38,6 +32,18 @@ def reset
3832
def press_me
3933
@back_color = color(200, 0, 0)
4034
end
35+
36+
def create_gui
37+
@skatolo = Skatolo.new(self)
38+
skatolo.add_button('press_me')
39+
.set_position(10, 10)
40+
.set_size(50, 20)
41+
.set_label('Press Me!')
42+
skatolo.add_button('reset')
43+
.set_position(10, 40)
44+
.set_size(50, 20)
45+
.set_label('Reset!')
46+
end
4147
end
4248

43-
SkatoloButtons.new
49+
ButtonDemo.new

external_library/gem/skatolo/jwishy.rb

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ def draw_shape(args)
8282
when 'triangle'
8383
draw_triangle(args)
8484
when 'square'
85-
rect(args[1], args[2], args[3], args[4])
85+
rect(*args.slice(1, 4))
8686
else
87-
oval(args[1], args[2], args[3], args[4]) # ellipse alias
87+
oval(*args.slice(1, 4)) # ellipse alias
8888
end
8989
end
9090

@@ -117,30 +117,20 @@ def create_gui
117117
.set_color_background(color(100))
118118
px = 10
119119
py = 15
120-
skatolo.add_slider('bluish')
121-
.set_size(sx, sy)
122-
.set_position(px, py += oy)
123-
.set_range(0, 1.0)
124-
.set_value(0.5)
125-
.set_group(control)
126-
skatolo.add_slider('alpha')
127-
.set_size(sx, sy)
128-
.set_position(px, py += oy)
129-
.set_range(0, 1.0)
130-
.set_value(0.5)
131-
.set_group(control)
132-
skatolo.add_button('toggle_big')
133-
.set_size(sx, 15)
134-
.set_position(px, py += oy)
135-
.set_group(control)
136-
skatolo.add_button('reset!')
137-
.set_size(sx, 15)
138-
.set_position(px, py += oy)
139-
.set_group(control)
140-
skatolo.add_button('random_shape')
141-
.set_size(sx, 15)
142-
.set_position(px, py += oy)
143-
.set_group(control)
120+
%w[bluish alpha].freeze.each do |slider|
121+
skatolo.add_slider(slider)
122+
.set_size(sx, sy)
123+
.set_position(px, py += oy)
124+
.set_range(0, 1.0)
125+
.set_value(0.5)
126+
.set_group(control)
127+
end
128+
%w[toggle_big reset! random_shape].freeze.each do |button|
129+
skatolo.add_button(button)
130+
.set_size(sx, 15)
131+
.set_position(px, py += oy)
132+
.set_group(control)
133+
end
144134
end
145135
end
146136

external_library/gem/skatolo/slider.rb

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
require 'skatolo'
44
# In this simple sketch we attach a slider to skatolo in the regular way, with
55
# a named slider 'background_color' and thanks to some fancy metaprogramming
6-
# we can read the result from background_color_value
7-
class SkatoloSlider < Propane::App
6+
# we can read the result from background_color_value in the sketch
7+
class SliderDemo < Propane::App
88
include EventMethod
99
attr_reader :skatolo
1010

@@ -14,19 +14,23 @@ def settings
1414

1515
def setup
1616
sketch_title 'Skatolo Slider'
17-
@skatolo = Skatolo.new(self)
18-
skatolo.add_slider('background_color')
19-
.set_position(10, 10)
20-
.set_size(150, 20)
21-
.set_range(80, 255)
22-
.set_value(180)
23-
.set_label('Background color')
24-
skatolo.update # this step is important
17+
create_gui
18+
skatolo.update # this step is important
2519
end
2620

2721
def draw
2822
background(background_color_value)
2923
end
24+
25+
def create_gui
26+
@skatolo = Skatolo.new(self)
27+
skatolo.add_slider('background_color')
28+
.set_position(10, 10)
29+
.set_size(150, 20)
30+
.set_range(80, 255)
31+
.set_value(180)
32+
.set_label('Background color')
33+
end
3034
end
3135

32-
SkatoloSlider.new
36+
SliderDemo.new
Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#!/usr/bin/env jruby
22
require 'propane'
33
require 'skatolo'
4-
# In this simple sketch we attach three buttons to skatolo in the regular way,
5-
# named buttons 'press_me' and 'reset' thanks to some fancy metaprogramming
6-
# we can create methods :red_color, :green_color and :blue_color for the buttons
7-
class SkatoloSliderGroup < Propane::App
8-
4+
# In this simple sketch we attach three sliders to skatolo in the regular way,
5+
# then group them and attach to an accordion widget, the slider values are sent
6+
# (auto-magically) to the sketch as red_value, green_value and blue_value
7+
class SliderGroupDemo < Propane::App
98
include EventMethod
109
attr_reader :skatolo, :back_color
1110

@@ -27,29 +26,19 @@ def draw
2726
def create_gui
2827
@skatolo = Skatolo.new(self)
2928
color_group = skatolo.add_group('colors')
30-
skatolo.add_slider('red')
31-
.set_group(color_group)
32-
.set_size(100, 15)
33-
.set_position(0, 10)
34-
.set_range(0, 255)
35-
.set_value(50)
36-
skatolo.add_slider('green')
37-
.set_group(color_group)
38-
.set_size(100, 15)
39-
.set_position(0, 30)
40-
.set_range(0, 255)
41-
.set_value(50)
42-
skatolo.add_slider('blue')
43-
.set_group(color_group)
44-
.set_size(100, 15)
45-
.set_position(0, 50)
46-
.set_range(0, 255)
47-
.set_value(50)
29+
%w[red green blue].freeze.each_with_index do |slider, index|
30+
skatolo.add_slider(slider)
31+
.set_group(color_group)
32+
.set_size(100, 15)
33+
.set_position(0, 10 + 20 * index)
34+
.set_range(0, 255)
35+
.set_value(50)
36+
end
4837
skatolo.add_accordion('acc')
4938
.set_position(10, 10)
5039
.set_size(120, 20)
5140
.add_item(color_group)
5241
end
5342
end
5443

55-
SkatoloSliderGroup.new
44+
SliderGroupDemo.new
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env jruby
2+
require 'propane'
3+
require 'skatolo'
4+
# In this simple sketch we attach a button to skatolo in the regular way,
5+
# and textfield widget. We can create a method :press_me and print the value of
6+
# the textfield, ps: make sure you do return on texfield entry
7+
class TextBoxDemo < Propane::App
8+
include EventMethod
9+
attr_reader :skatolo, :back_color, :font, :name
10+
11+
def settings
12+
size(400, 300)
13+
end
14+
15+
def setup
16+
sketch_title 'Skatolo Text Box'
17+
create_gui
18+
skatolo.update # this step is important
19+
@back_color = color(200, 0, 200)
20+
text_font(create_font('monospace', 30))
21+
@name = ''
22+
end
23+
24+
def press_me
25+
text("Hello #{name}", 10,120)
26+
@name = ''
27+
end
28+
29+
def draw
30+
background(back_color)
31+
@name = input_name_value if name.length.zero?
32+
end
33+
34+
def create_gui
35+
@skatolo = Skatolo.new(self)
36+
skatolo.add_button('press_me')
37+
.set_position(10, 10)
38+
.set_size(50, 20)
39+
.set_label('Press Me!')
40+
@input = skatolo.add_textfield('input_name')
41+
.set_position(10, 50)
42+
.set_size(100, 20)
43+
.set_auto_clear(true)
44+
end
45+
end
46+
47+
TextBoxDemo.new

0 commit comments

Comments
 (0)