add reset functionality
parent
ccc364e644
commit
6bc2c3f06d
|
|
@ -88,6 +88,7 @@ fig[2, 1] = buttongrid = GridLayout(tellwidth=false)
|
|||
btn_step = Button(buttongrid[1, 1], label="Step")
|
||||
btn_start = Button(buttongrid[1, 2], label="Start")
|
||||
btn_stop = Button(buttongrid[1, 3], label="Stop")
|
||||
btn_reset = Button(buttongrid[1, 4], label="Reset")
|
||||
|
||||
|
||||
fig[3, 1] = textboxgrid = GridLayout(tellwidth=false)
|
||||
|
|
@ -97,6 +98,15 @@ box_u = Textbox(textboxgrid[1, 1], validator=Float64, placeholder="word")
|
|||
# box_kill = Textbox(textboxgrid[1, 4], validator=Float64, placeholder="word")
|
||||
# Timer and state for animation
|
||||
running = Observable(false)
|
||||
function reset!(U, V, heat_obs)
|
||||
U .= 1.0
|
||||
V .= 0.0
|
||||
center = size(U, 1) ÷ 2
|
||||
radius = 10
|
||||
U[center-radius:center+radius, center-radius:center+radius] .= 0.50
|
||||
V[center-radius:center+radius, center-radius:center+radius] .= 0.25
|
||||
heat_obs[] = copy(U)
|
||||
end
|
||||
|
||||
function animation_loop()
|
||||
while running[]
|
||||
|
|
@ -108,6 +118,7 @@ end
|
|||
on(box_u.stored_string) do s
|
||||
try
|
||||
Du[] = parse(Float64, s)
|
||||
println("Change Du ", Du[])
|
||||
catch
|
||||
@warn "Invalid input for Du: $s"
|
||||
end
|
||||
|
|
@ -128,4 +139,9 @@ on(btn_stop.clicks) do _
|
|||
running[] = false
|
||||
end
|
||||
|
||||
on(btn_reset.clicks) do _
|
||||
running[] = false
|
||||
reset!(U, V, heat_obs)
|
||||
|
||||
end
|
||||
display(fig)
|
||||
|
|
|
|||
Loading…
Reference in New Issue