Skip to content

Commit df27ad3

Browse files
committed
One more slider
1 parent 4a28fff commit df27ad3

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

examples/sliders.jl

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,23 @@ A = Observable(20.0) # width of the figure-eight
1818
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
21-
x0 = 0.0 # center x-coordinate
21+
x0 = Observable(0.0) # center x-coordinate
2222
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, y0)
26+
function figure_eight_y(A, B, C, D, x0, 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, y0)
31+
function figure_eight_x(A, B, C, D, x0, 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, $y0))
37-
x = @lift(figure_eight_x($A, $B, $C, $D, $y0))
36+
y = @lift(figure_eight_y($A, $B, $C, $D, $x0, $y0))
37+
x = @lift(figure_eight_x($A, $B, $C, $D, $x0, $y0))
3838

3939
# Create the figure and axis
4040
fig = Figure()
@@ -53,6 +53,7 @@ sg = SliderGrid(
5353
(label = "B (height)", range = 5:0.01:20.0, startvalue = 10.0),
5454
(label = "C (right_size)", range = -2.0:0.01:2.0, startvalue = 0.0),
5555
(label = "D (asymmetry)", range = -3:0.01:3.0, startvalue = 0.0),
56+
(label = "x0", range = -10:0.01:10.0, startvalue = 0.0),
5657
(label = "y0", range = 20:0.01:30.0, startvalue = 25.0)
5758
)
5859

@@ -74,6 +75,10 @@ on(sg.sliders[4].value) do val
7475
end
7576

7677
on(sg.sliders[5].value) do val
78+
x0[] = val
79+
end
80+
81+
on(sg.sliders[6].value) do val
7782
y0[] = val
7883
end
7984

0 commit comments

Comments
 (0)