Skip to content

Commit 9aed4f6

Browse files
committed
Simpler control panel UI
1 parent 47af2c0 commit 9aed4f6

File tree

15 files changed

+36
-135
lines changed

15 files changed

+36
-135
lines changed

contributed/bezier_playground.rb

+1-6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
class BezierPlayground < Propane::App
1313
load_libraries :control_panel, :curve
1414
include Olap
15-
attr_reader :curves, :c1x, :c1y, :c2x, :c2y, :panel, :hide
15+
attr_reader :curves, :c1x, :c1y, :c2x, :c2y
1616

1717
def settings
1818
size 300, 300
@@ -28,16 +28,11 @@ def setup
2828
c.look_feel 'Nimbus'
2929
c.button :new_curve
3030
c.button :print_equations
31-
@panel = c
3231
end
3332
generate_curve
3433
end
3534

3635
def draw
37-
unless hide
38-
panel.set_visible true
39-
@hide = true
40-
end
4136
background 50
4237
draw_control_tangent_lines
4338
draw_curves

contributed/jwishy.rb

+2-13
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
class JWishy < Propane::App
66
load_library :control_panel
77

8-
attr_reader :alpha, :back_color, :bluish, :hide, :magnitude, :panel
8+
attr_reader :alpha, :back_color, :bluish, :magnitude
99
attr_reader :x_wiggle, :y_wiggle, :go_big, :shape
1010

1111
def settings
@@ -16,13 +16,12 @@ def setup
1616
sketch_title 'Wishy Worm'
1717
control_panel do |c|
1818
c.title 'Control Panel'
19-
c.look_feel 'Motif'
19+
c.look_feel 'Nimbus'
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
2323
c.button :reset
2424
c.menu :shape, %w(oval square triangle), 'oval'
25-
@panel = c
2625
end
2726
@hide = false
2827
@x_wiggle, @y_wiggle = 10.0, 0
@@ -43,11 +42,6 @@ def reset
4342
end
4443

4544
def draw
46-
# only make control_panel visible once, or again when hide is false
47-
unless hide
48-
@hide = true
49-
panel.set_visible(hide)
50-
end
5145
draw_background
5246
# Seed the random numbers for consistent placement from frame to frame
5347
srand(0)
@@ -74,11 +68,6 @@ def draw
7468
@y_wiggle += 0.1
7569
end
7670

77-
def mouse_pressed
78-
return unless hide
79-
@hide = false
80-
end
81-
8271
def draw_shape(args)
8372
case args[0]
8473
when 'triangle'

contributed/quadraticvertex.rb

+3-8
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,24 @@
88
# Note how to specify fill and background using hexadecimal string for color,
99
# this is different from vanilla processing
1010
class Quadraticvertex < Propane::App
11-
1211
load_library :control_panel
1312

14-
attr_reader :debug, :save_one, :step_angle, :cr, :detail, :panel, :hide
13+
attr_reader :debug, :save_one, :step_angle, :cr, :detail
1514

1615
def setup
1716
sketch_title 'Quadratic Vertex'
1817
@hide = false
1918
control_panel do |c|
2019
c.title 'Controller'
20+
c.look_feel 'Nimbus'
2121
c.menu(:detail, %w(4 5 6 7 8 9 10), '7')
2222
c.checkbox :debug
2323
c.button :save_image
24-
@panel = c
2524
end
2625
@save_one = false
2726
end
2827

2928
def draw
30-
unless hide
31-
panel.set_visible true
32-
@hide = true
33-
end
3429
background color('#BDF018')
3530
translate width / 2, height / 2
3631
@step_angle = TAU / (detail.to_i - 1)
@@ -67,7 +62,7 @@ def draw
6762
end
6863
end
6964
return unless save_one
70-
save_frame('images/quadraticvertex-#####.png')
65+
save_frame(data_path('quadraticvertex-#####.png'))
7166
@save_one = false
7267
end
7368

examples/grid_method/luciernagas.rb

+3-9
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Luciernagas < Propane::App
99

1010
load_library :control_panel
1111

12-
attr_reader :panel, :hide, :image_mask, :spots
12+
attr_reader :image_mask, :spots
1313
ACCURACY = 4
1414

1515
# Firefly holder
@@ -31,9 +31,7 @@ def setup
3131
control.slider(:target_radius, 5...100, 20)
3232
control.slider(:spot_distance, 5..200, 80)
3333
control.button :reset
34-
@panel = control
3534
end
36-
@hide = false
3735
@spotlight = create_spotlight
3836
@background = load_image(data_path('background.png'))
3937
@image_mask = load_image(data_path('mask.png'))
@@ -46,10 +44,6 @@ def reset
4644
end
4745

4846
def draw
49-
unless hide
50-
@hide = true
51-
panel.set_visible(hide)
52-
end
5347
image @background, 0, 0
5448
draw_lights
5549
draw_flyers
@@ -129,9 +123,9 @@ def draw_tail(flyer)
129123
def load_spots(spot_image, accuracy = ACCURACY)
130124
@spots = []
131125
spot_image.load_pixels
132-
corner_color = spot_image.get 0, 0
126+
corner_color = spot_image.pixels[0]
133127
grid(spot_image.width, spot_image.height, accuracy, accuracy) do |x, y|
134-
color = spot_image.get(x, y)
128+
color = spot_image.pixels[x + y * spot_image.width]
135129
spots << Vec2D.new(x, y) if color != corner_color
136130
end
137131
end

external_library/gem/toxiclibs/boolean_shapes.rb

+1-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# The Sketch Class
77
class BooleanShapes < Propane::App
88
load_library :control_panel
9-
attr_reader :gfx, :bool, :panel, :type, :hide, :polies
9+
attr_reader :gfx, :bool, :type, :polies
1010
include Toxi
1111

1212
TYPE = [BooleanShapeBuilder::Type::UNION,
@@ -20,16 +20,10 @@ def setup
2020
control_panel do |c|
2121
c.title 'Select Type'
2222
c.menu :type, KEY, 'union'
23-
@panel = c
2423
end
25-
@hide = false
2624
end
2725

2826
def draw
29-
unless hide
30-
@hide = true
31-
panel.set_visible(hide)
32-
end
3327
background(160)
3428
builder = BooleanShapeBuilder.new(bool[type])
3529
phi = frame_count * 0.01

external_library/java/pixel_flow/image_processing_filter.rb

+8-9
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class ImageProcessingFilters < Propane::App
2020
filters.each do |filter|
2121
java_import format(filter_format, filter)
2222
end
23-
java_import 'com.jogamp.opengl.GL'
23+
java_import com.jogamp.opengl.GL
2424

2525
GUI_WIDTH = 200
2626
VIEW_WIDTH = 927
@@ -109,7 +109,7 @@ class ImageProcessingFilters < Propane::App
109109
attr_reader :tex_A, :pg_src_A, :pg_src_B, :pg_src_C, :cp5, :hide
110110
attr_reader :pg_voronoi_centers, :laplace_weight
111111
attr_reader :show_geom, :show_image, :animations, :passes
112-
attr_reader :rs, :vel, :pos, :panel, :filters, :blur_radius, :conv_kernel_idx
112+
attr_reader :rs, :vel, :pos, :filters, :blur_radius, :conv_kernel_idx
113113

114114
def settings
115115
size VIEW_WIDTH, VIEW_HEIGHT, P2D
@@ -154,6 +154,12 @@ def setup
154154
pg_voronoi_centers.point(px + 0.5, py + 0.5)
155155
end
156156
pg_voronoi_centers.end_draw
157+
setup_control_panel
158+
# frame_rate(60)
159+
frame_rate(1000)
160+
end
161+
162+
def setup_control_panel
157163
control_panel do |c|
158164
c.look_feel 'Nimbus'
159165
c.title 'Filter Chooser and Settings'
@@ -165,17 +171,10 @@ def setup
165171
c.checkbox :show_image, true
166172
c.checkbox :show_geom, true
167173
c.checkbox :animations, true
168-
@panel = c
169174
end
170-
# frame_rate(60)
171-
frame_rate(1000)
172175
end
173176

174177
def draw
175-
unless hide
176-
@hide = true
177-
panel.set_visible(hide)
178-
end
179178
current = FILTERS.index(filters)
180179
convolution_kernel_index = conv_kernel_idx.to_i
181180
gaussblur_sigma = blur_radius / 2.0

processing_app/library/control_panel/button.rb

+1-8
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@
33
class SimpleButton < Propane::App
44
load_library :control_panel
55

6-
attr_reader :hide, :panel, :back
7-
6+
attr_reader :back
87
def setup
98
sketch_title 'Simple Button'
109
control_panel do |c|
1110
c.look_feel 'Nimbus'
1211
c.title 'Control Button'
1312
c.button :color_background # see method below
1413
c.button(:exit!) { exit } # example of a button with a simple block
15-
@panel = c
1614
end
1715
color_mode RGB, 1
1816
@back = [0, 0, 1.0]
@@ -23,11 +21,6 @@ def color_background
2321
end
2422

2523
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
3124
background *back
3225
end
3326

processing_app/library/control_panel/checkbox.rb

+3-9
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,26 @@
22
require 'propane'
33
class Checkbox < Propane::App
44
load_library :control_panel
5-
6-
attr_reader :hide, :panel, :shouting
5+
WARN = 'warning!'.freeze
6+
attr_reader :shouting
77

88
def setup
99
sketch_title 'Simple Checkbox'
1010
control_panel do |c|
1111
c.look_feel 'Nimbus'
1212
c.title 'Checkbox'
1313
c.checkbox :shouting
14-
@panel = c
1514
end
1615
text_font(create_font('mono', 48))
1716
fill(200, 0, 0)
1817
end
1918

2019
def warning
21-
shouting ? 'WARNING!' : 'warning!'
20+
shouting ? WARN.upcase : WARN
2221
end
2322

2423
def draw
2524
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
3125
text(warning, 20, 100)
3226
end
3327

processing_app/library/control_panel/menu.rb

+1-8
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,17 @@
33
class SimpleMenu < Propane::App
44
load_library :control_panel
55

6-
attr_reader :hide, :panel, :toggle_loop
6+
attr_reader :toggle_loop
77
def setup
88
sketch_title 'Simple Menu'
99
control_panel do |c|
10-
c.look_feel 'Motif'
1110
c.title 'Menu'
1211
c.menu :choice, %i[one two three]
1312
c.checkbox(:toggle_loop) { toggle_loop ? loop : no_loop}
14-
@panel = c
1513
end
1614
end
1715

1816
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
2417
puts @choice
2518
no_loop
2619
end

processing_app/library/control_panel/slider.rb

+1-8
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,17 @@
33
class SimpleSlider < Propane::App
44
load_library :control_panel
55

6-
attr_reader :hide, :panel, :bluish
6+
attr_reader :bluish
77
def setup
88
sketch_title 'Simple Slider'
99
control_panel do |c|
10-
c.look_feel 'Motif'
1110
c.title 'Slider'
1211
c.slider :bluish, 0.2..1.0, 0.5
13-
@panel = c
1412
end
1513
color_mode(RGB, 1.0)
1614
end
1715

1816
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
2417
background(0, 0, bluish)
2518
end
2619

processing_app/library/vecmath/vec2d/penrose.rb

+3-11
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# Translated (and refactored) to JRubyArt July 2015 by Martin Prout
1010
class Penrose < Propane::App
1111
load_library :control_panel
12-
attr_reader :tris, :s, :panel, :hide, :acute
12+
attr_reader :tris, :s, :acute
1313

1414
def setup
1515
sketch_title 'Penrose'
@@ -20,23 +20,14 @@ def setup
2020
c.checkbox :acute
2121
c.button :generate
2222
c.button :reset!
23-
@panel = c
2423
end
25-
@hide = false
2624
init false # defaults to regular penrose
2725
end
2826

2927
def draw
30-
# only make control_panel visible once, or again when hide is false
31-
unless hide
32-
@hide = true
33-
panel.set_visible(hide)
34-
end
3528
background(255)
3629
translate(width / 2, height / 2)
37-
tris.each do |t|
38-
t.display
39-
end
30+
tris.each(&:display)
4031
end
4132

4233
def generate
@@ -78,4 +69,5 @@ def settings
7869
size 1024, 576
7970
end
8071
end
72+
8173
Penrose.new

0 commit comments

Comments
 (0)