Skip to content

Commit a1d6567

Browse files
committed
update/add control_panel examples
1 parent 4ae224e commit a1d6567

File tree

8 files changed

+148
-5
lines changed

8 files changed

+148
-5
lines changed

contributed/jwishy.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ def settings
1515
def setup
1616
sketch_title 'Wishy Worm'
1717
control_panel do |c|
18-
c.title = 'Control Panel'
19-
c.look_feel 'Nimbus'
18+
c.title 'Control Panel'
19+
c.look_feel 'Motif'
2020
c.slider :bluish, 0.0..1.0, 0.5
2121
c.slider :alpha, 0.0..1.0, 0.5
2222
c.checkbox :go_big, false

contributed/quadraticvertex.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def setup
1717
sketch_title 'Quadratic Vertex'
1818
@hide = false
1919
control_panel do |c|
20-
c.title = 'Controller'
20+
c.title 'Controller'
2121
c.menu(:detail, %w(4 5 6 7 8 9 10), '7')
2222
c.checkbox :debug
2323
c.button :save_image
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env jruby -w
2+
require 'propane'
3+
class SimpleButton < Propane::App
4+
load_library :control_panel
5+
6+
attr_reader :hide, :panel, :back
7+
8+
def setup
9+
sketch_title 'Simple Button'
10+
control_panel do |c|
11+
c.look_feel 'Nimbus'
12+
c.title 'Control Button'
13+
c.button :color_background # see method below
14+
c.button(:exit!) { exit } # example of a button with a simple block
15+
@panel = c
16+
end
17+
color_mode RGB, 1
18+
@back = [0, 0, 1.0]
19+
end
20+
21+
def color_background
22+
@back = [rand, rand, rand]
23+
end
24+
25+
def draw
26+
# only make control_panel visible once, or again when hide is false
27+
unless hide
28+
@hide = true
29+
panel.set_visible(hide)
30+
end
31+
background *back
32+
end
33+
34+
def settings
35+
size 300, 300
36+
end
37+
end
38+
39+
SimpleButton.new
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env jruby -w
2+
require 'propane'
3+
class Checkbox < Propane::App
4+
load_library :control_panel
5+
6+
attr_reader :hide, :panel, :shouting
7+
8+
def setup
9+
sketch_title 'Simple Checkbox'
10+
control_panel do |c|
11+
c.look_feel 'Nimbus'
12+
c.title 'Checkbox'
13+
c.checkbox :shouting
14+
@panel = c
15+
end
16+
text_font(create_font('mono', 48))
17+
fill(200, 0, 0)
18+
end
19+
20+
def warning
21+
shouting ? 'WARNING!' : 'warning!'
22+
end
23+
24+
def draw
25+
background 0
26+
# only make control_panel visible once, or again when hide is false
27+
unless hide
28+
@hide = true
29+
panel.set_visible(hide)
30+
end
31+
text(warning, 20, 100)
32+
end
33+
34+
def settings
35+
size 300, 300
36+
end
37+
end
38+
39+
Checkbox.new
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env jruby -w
2+
require 'propane'
3+
class SimpleMenu < Propane::App
4+
load_library :control_panel
5+
6+
attr_reader :hide, :panel, :toggle_loop
7+
def setup
8+
sketch_title 'Simple Menu'
9+
control_panel do |c|
10+
c.look_feel 'Motif'
11+
c.title 'Menu'
12+
c.menu :choice, %i[one two three]
13+
c.checkbox(:toggle_loop) { toggle_loop ? loop : no_loop}
14+
@panel = c
15+
end
16+
end
17+
18+
def draw
19+
# only make control_panel visible once, or again when hide is false
20+
unless hide
21+
@hide = true
22+
panel.set_visible(hide)
23+
end
24+
puts @choice
25+
no_loop
26+
end
27+
28+
def settings
29+
size 300, 300
30+
end
31+
end
32+
33+
SimpleMenu.new
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env jruby -w
2+
require 'propane'
3+
class SimpleSlider < Propane::App
4+
load_library :control_panel
5+
6+
attr_reader :hide, :panel, :bluish
7+
def setup
8+
sketch_title 'Simple Slider'
9+
control_panel do |c|
10+
c.look_feel 'Motif'
11+
c.title 'Slider'
12+
c.slider :bluish, 0.2..1.0, 0.5
13+
@panel = c
14+
end
15+
color_mode(RGB, 1.0)
16+
end
17+
18+
def draw
19+
# only make control_panel visible once, or again when hide is false
20+
unless hide
21+
@hide = true
22+
panel.set_visible(hide)
23+
end
24+
background(0, 0, bluish)
25+
end
26+
27+
def settings
28+
size 300, 300
29+
end
30+
end
31+
32+
SimpleSlider.new

processing_app/library/vecmath/vec2d/penrose.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Penrose < Propane::App
1414
def setup
1515
sketch_title 'Penrose'
1616
control_panel do |c|
17-
c.title = 'Tiler Control'
17+
c.title 'Tiler Control'
1818
c.look_feel 'Nimbus'
1919
c.checkbox :seed
2020
c.checkbox :acute

processing_app/topics/lsystems/three_d_tree.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def setup
2424

2525
def setup_panel
2626
control_panel do |c|
27-
c.title = 'Control:'
27+
c.title 'Control:'
2828
c.look_feel 'Metal'
2929
c.slider :zoom, 1..8, 3
3030
c.slider :rot_y, -PI..PI, 0

0 commit comments

Comments
 (0)