Skip to content

Commit 4a28fff

Browse files
committed
Better labels
1 parent 7dc61b0 commit 4a28fff

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

examples/sliders.jl

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,22 @@ B = Observable(10.0) # height of the figure-eight
1919
C = Observable(0.0) # size of right part of the figure-eight
2020
D = Observable(0.0) # asymmetry factor
2121
x0 = 0.0 # center x-coordinate
22-
y0 = 25.0 # center y-coordinate
22+
y0 = Observable(25.0) # center y-coordinate
2323
theta = 0*π/6 # rotation angle in radians
2424
num_points = 200
2525

26-
function figure_eight_y(A, B, C, D)
26+
function figure_eight_y(A, B, C, D, y0)
2727
x, y = figure_eight_path(A, B, C, D, x0, y0, theta, num_points)
2828
return y
2929
end
3030

31-
function figure_eight_x(A, B, C, D)
31+
function figure_eight_x(A, B, C, D, y0)
3232
x, y = figure_eight_path(A, B, C, D, x0, y0, theta, num_points)
3333
return x
3434
end
3535

36-
y = @lift(figure_eight_y($A, $B, $C, $D))
37-
x = @lift(figure_eight_x($A, $B, $C, $D))
36+
y = @lift(figure_eight_y($A, $B, $C, $D, $y0))
37+
x = @lift(figure_eight_x($A, $B, $C, $D, $y0))
3838

3939
# Create the figure and axis
4040
fig = Figure()
@@ -49,10 +49,11 @@ xlims!(ax, -30, 30)
4949
# Create sliders for amplitude and frequency
5050
sg = SliderGrid(
5151
fig[2, 1],
52-
(label = "A", range = 10:0.01:30.0, startvalue = 20.0),
53-
(label = "B", range = 5:0.01:20.0, startvalue = 10.0),
54-
(label = "C", range = -2.0:0.01:2.0, startvalue = 0.0),
55-
(label = "D", range = -3:0.01:3.0, startvalue = 0.0)
52+
(label = "A (width)", range = 10:0.01:30.0, startvalue = 20.0),
53+
(label = "B (height)", range = 5:0.01:20.0, startvalue = 10.0),
54+
(label = "C (right_size)", range = -2.0:0.01:2.0, startvalue = 0.0),
55+
(label = "D (asymmetry)", range = -3:0.01:3.0, startvalue = 0.0),
56+
(label = "y0", range = 20:0.01:30.0, startvalue = 25.0)
5657
)
5758

5859
# Connect sliders to observables
@@ -72,4 +73,9 @@ on(sg.sliders[4].value) do val
7273
D[] = val
7374
end
7475

76+
on(sg.sliders[5].value) do val
77+
y0[] = val
78+
end
79+
80+
7581
fig

0 commit comments

Comments
 (0)