@@ -19,22 +19,22 @@ B = Observable(10.0) # height of the figure-eight
1919C = Observable (0.0 ) # size of right part of the figure-eight
2020D = Observable (0.0 ) # asymmetry factor
2121x0 = 0.0 # center x-coordinate
22- y0 = 25.0 # center y-coordinate
22+ y0 = Observable ( 25.0 ) # center y-coordinate
2323theta = 0 * π/ 6 # rotation angle in radians
2424num_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
2929end
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
3434end
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
4040fig = Figure ()
@@ -49,10 +49,11 @@ xlims!(ax, -30, 30)
4949# Create sliders for amplitude and frequency
5050sg = 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
7374end
7475
76+ on (sg. sliders[5 ]. value) do val
77+ y0[] = val
78+ end
79+
80+
7581fig
0 commit comments