Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interaction with fps from Reactive.jl #346

Closed
stakaz opened this issue Dec 11, 2019 · 2 comments
Closed

Interaction with fps from Reactive.jl #346

stakaz opened this issue Dec 11, 2019 · 2 comments

Comments

@stakaz
Copy link

stakaz commented Dec 11, 2019

Hello, I am trying to do an animation of a simulation process and would like to have a time signal which updates the plot (beside other sliders). I am trying to reproduce examples from #36 but timestamp does not work anymore and I cannot figure out how to combine the fps from Reactive.jl and make it a trigger for the Widget.

Would be glad to see some hints.

Here is the code which does not work:

using Blink
using Compose, Reactive, Interact
anim = @manipulate for x=fps(10.0), color=["tomato", "bisque"], gravity=0:.1:2
	compose(context(0.5, 1-abs(sin(x[1]*gravity)), 0.1, 0.1), fill(color), circle())
end 

w = Window(async = false)
wdg = Widget(["anim" => anim])
body!(w, wdg);

I need the Blink package because I am using julia from within VS code and want a separate window with the animation.

Thanks.

@stakaz
Copy link
Author

stakaz commented Dec 12, 2019

I found this notebook which can do what I want:
https://github.com/JuliaGizmos/Interact.jl/blob/master/doc/notebooks/04-Animations.ipynb

This is the "nearly" working example.

using Blink
using Interact
using Reactive
using GR
GR.inline()

lhs = slider(1:0.1:10) |> onchange

Λ = rand(Int8[-1,1], 10, 10)

timer = Observable(0.0)
t = @async while true
    sleep(0.1)
    timer[] += 0.1
end

function test_plot(t, Λ, args...)
	for i  eachindex(Λ)
		Λ[i] = rand(Int8[-1,1])
	end
	heatmap.* t)
end

result = map(test_plot, lhs, Λ, timer)

widget = vbox(lhs, result)

window = Window()
body!(window, widget)

However, after the code is run for the first time there is the async job which never ends. Would it be possible to stop it once the Blink window is closed?

This is the error I get for the following code after I close the Blink window.

Info: Connection is not open.
└   connection = Blink.AtomShell.WebIOBlinkComm(Window(1, Electron(Process(`/home/gluon/.julia/packages/Blink/AO8uN/deps/atom/electron /home/gluon/.julia/packages/Blink/AO8uN/src/AtomShell/main.js port 3528`, ProcessRunning), Sockets.TCPSocket(RawFD(0x00000023) active, 0 bytes waiting), Dict{String,Any}("callback"=>##1#2())), Page(1, WebSocket(server, CLOSED), Dict{String,Any}("webio"=>##26#27{WebIOBlinkComm}(WebIOBlinkComm(#= circular reference @-5 =#)),"callback"=>##1#2()), Distributed.Future(1, 1, 1, Some(true))), Task (done) @0x00007ff88ea7a710))

@twavv
Copy link
Member

twavv commented Jan 2, 2020

The latter (connection closed warning) is an issue with WebIO.

If you'd be willing to open an issue there, I'd be much obliged.

@twavv twavv closed this as completed Jan 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants