-
-
Notifications
You must be signed in to change notification settings - Fork 294
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
Does this physics interactive buttons can be done in Pluto.jl [1] #2986
Comments
I think I've got something:
This script will capture the click event for any of the three buttons. If the user clicks the |
Hey @f0nzie ! That looks super fun! I love the picture on the top left :) Consider sending the notebook file when you're done, I would love to see! The solution you came up with is exactly what I would suggest, great! I would say that this JS widget should also fire tick events, just like You can also set In your Julia code, you can use @bind x MyTimeWidget() begin
x # refernce for trigger
update_simulation!(state)
end StatelessSomething I prefer is to make it stateless: states = Dict(0 => initial_state) get_state_at(time::Integer) =
get!(states, time) do
prev_state = get_state_at(time - 1)
step_simulation(prev_state)
end @bind x MyTimeWidget() get_state_at(x) -fonzie |
Hi @fonsp ,
This is the notebook: and a newer one, passing an argument: |
What is the purpose of making the |
If you are interested in seeing how the simulation buttons work in the original Java application, I am sharing a JAR file with a whole bunch of simulation demos. The one I showed in the post is in Chapter 12. See screenshot. To run the app, simply unzip the file. On the location where you have |
I have been looking for examples in Julia and Pluto to reproduce these simulations done in Java a long time ago.
The "Start" button starts the simulation. Immediately after pressing "Start", the button changes its label to "Stop", and the two buttons on the right "Step" and "New" are greyed out (disabled). The button "Step" would allow the user to advance the simulation one$\Delta t$ at a time. The "New" button just enable the input panel for a new entry and offers the user the options of "Initialize" (stores the changes) and "Reset" (clear all values preset to default).
After the simulation is stopped, the buttons "Step" and "New" are enabled again, allowing the user to resume the simulation by clicking step by step, or start over with a new set of values with New.
The "New" button will bring a new front end, with the buttons "Initialize" and "Reset".
I have been playing a bit with the buttons and the JS custom made button but I am not versed enough in JS to make the label change (from Initialize) to a new one (Start), and then to another one (Stop), when the state of the simulation is changed by the user.
Any thoughts?
The text was updated successfully, but these errors were encountered: