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

Example of DSim + Quil integration #6

Open
kot-behemoth opened this issue Oct 26, 2021 · 3 comments
Open

Example of DSim + Quil integration #6

kot-behemoth opened this issue Oct 26, 2021 · 3 comments

Comments

@kot-behemoth
Copy link

I've been trying to learn DSim to do animation using Quil. While going through the docs, there is a mention of Quil integration and how animation is one of the things DSim can help with:

When it comes to the huge topic of any form of animation, offline or online ones, the Clojure community is well endowed by having the Quil library

Now, as a newbie there is quite a lot to grok in Dsim, and the docs show useful code snippets. However, it still is quite difficult to jump from an abstract concept to a simple toy example (might just be that I'm also quite new to Clojure). It would be great if there was one or several runnable examples available.

In particular, it could be really helpful to see a simple example of how exactly an animation can be done using DSim + Quil combination. Even just giving an actual runnable example from the docs:

For instance, suppose this simple animation: an object moving on its X axis from pixel 200 to pixel 800 during 2000 milliseconds, in a universe where time units are indeed milliseconds. Using our infrastructure, it is a matter of barely a few lines of code to write a flow that can move anything from A to B.

The main issue I can see people like myself encountering is how DSim's ctx would play with Quil's fun-mode - and whether you even need it when one is using DSim.

P.S. I watched the wonderful referenced animation, and am really excited to try using DSim for animation!

P.P.S. I understand that asking for examples and docs improvement can be a big ask for maintainers. If someone was able to provide some samples for Quil, I'd be happy to turn them into a runnable example as a PR.

@helins
Copy link
Owner

helins commented Oct 31, 2021

Hi,

A ctx is functionnally pure, it's just Clojure data structures and functions, so using fun-mode can help with state management. Indeed, writing Quil examples would be too time consuming at the moment. Overall, it depends how comfortable you are both with Quil and DSim. I have had mixed responses for DSim, where people either understand very well where this is going or have a hard time. So I find it hard to target both. I would advice to just focus on DSim for the moment, without any drawing whatsoever, just get how it works.

Then I hope it becomes more straightforward to imagine how to use it for drawing since this is just about managing state over time. There is nothing too specific about that state when it comes to drawing, akin to how Re-frame uses generic Clojure data structures for building UIs for instance.

I know @flyingmachine has been grokking with animation but I don't know how far or how well that went :)

@flyingmachine
Copy link

flyingmachine commented Nov 6, 2021

My little dsim/d3 experiment went well! The animation was meant to show requests and responses for a collection of nodes in a server cluster.

I used dsim to model request timelines, something along the lines of:

  • At t0 (time 0) msg0..8 (messages 0-8) are at n0 (node 0)
  • At t15 msg0..2 are at n1, msg3..5 are at n2
  • at t18 msg6..8 are at n3

This dsim timeline would describe the location of each request in reference to time zero. To produce animations, however, I needed the duration of each message's trip between nodes; if msg5 is at n1 at t15 and n2 at t30, the duration is 15. That just required writing a little helper function to derive these values from the dsim timeline data.

Hope this helps.

@helins
Copy link
Owner

helins commented Nov 8, 2021

Thanks!
(feel free to share if there is something online :) )

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

3 participants