usingColorsusingAbstractPlotting"""
This example is courtesy of @neuralian through the Julia Discourse.
https://discourse.julialang.org/t/makie-interaction-slider-with-animation/25179/10
"""x₀=-5.0#gateState = falsex_range=10.0# deflectionp₀(x)=x/2.0# plotn_points=100.0x=(x₀.+collect((-n_points/2.0):(n_points/2.0))/n_points*x_range)scene=lines(x,p₀(x),linewidth=4,color=:darkcyan,leg=false)axis=scene[Axis]axis[:names][:axisnames]=("x","y")D=Node(x₀)HC_handle=scatter!(lift(x->[x],D),[2.0],marker=:circle,markersize=1.0,color=:red)[end]s1=slider(LinRange(-10.0,0.0,101),raw=true,camera=campixel!,start=-10.0)kx=s1[end][:value]scatter!(scene,lift(x->[x;x],kx),lift(x->[0.5;p₀(x)],kx),marker=:hexagon,color=RGBA(0.5,0.0,0.5,0.5),markersize=0.35,strokewidth=0.01,strokecolor=:black)S=Scene(resolution=(800,600))hbox(scene,s1;parent=S)@asyncbeginwhile!isopen(S)# wait for screen to be opensleep(0.01)endwhileisopen(S)p=p₀((10.0+kx[])/10.0)gateState=rand(1)[]<pHC_handle[:color]=gateState?:gold1::dodgerblue1D[]=-3.0+rand()/5.0sleep(0.001)endend# Do not execute beyond this point!RecordEvents(S,"output");