How to create a graphic simulator?

Julia has MANY packages to create static vector graphics. But I want to create a simulation. A RealTime simulation. I don’t want to create GIFs or MP4s or anything. Realtime simulations that render in a window. And I am not talking about plots either. I want to simulate particles with my own physics. How do I do it? I want something that has the following:

  • A graphics window.
  • High-speed rendering
  • CLEAN-looking graphics. (A circle should look smooth, maybe anti-aliasing or vectors idk)
  • I don’t know technical stuff but ig in 2D rendering, objects are stored as sprites.
  • I should be able to create objects like circles, rectangles, lines, curves, etc…
  • It should have a render loop
  • I should be able to set a frame rate limit
  • I should be able to time things (movement of sprites… perhaps frame by frame?)
  • And finally… at least some ease of use.

GameZero.jl seems pretty good for that but I don’t think it’s high performance. As the creators suggest, it’s for “Beginner purposes”. Besides, I don’t see any frame rate option there (please tell me if I’m wrong).
ModernGL + GLFW seems promising but it’s almost the same as using the native c++. So why do it in Julia if I am using c++ like syntax after all? (And I really don’t want to learn c++ at the moment)

Luxor provides static vectors (It’s great looking but I want to simulate in real-time, not prerender)

Makie seems to be a plotting thing… (please correct me if I’m wrong)

SFML.jl library seems to be totally abandoned by the creator. (CSFML doesn’t seem correct for some syntactical reason)

GTK.jl seems ugly looking, inefficient and what not.

Please recommend a way out. I want to create something like Particle Life but extended as per my own needs. I have no issues spending time learning. But at least the final result should be promising and fast. (do recommend examples and tutorials for a library/package if you can think of any.)


Let me correct you, because you’re wrong :smiley:

Plotting is just visualization with certain conveniences, like axes, colorbars, etc. But all these are built from primitives like scatters and lines and those you can use directly for lower-level simulations. I assume you just want a blank canvas in which to draw things, and update them.

If you don’t want any plotting bells and whistles, you use a plain Scene, for example with a campixel! function as camera parameter, which will make it so you draw things in pixel coordinates.

using GLMakie

    s = Scene(resolution = (800, 800), camera = campixel!)
    data = Observable(rand(Point2f, 10_000) .* Point2f(800, 800))
    scatter!(s, data, color = rand(10_000))
    screen = display(s)
    task = @async while isopen(screen)
        data[] .+= randn.(Point2f)

:sob::sob: Thank you so much!!!

Assuming that’s a live window, how do I time things? sleep would stop all the processes I assume, including the computational work in the bg.
Apart from that, just 1 question, Ummm… is it like… fast? REAL FAST? can I get high fps here?
Also, any easy-to-follow tutorials.
How to make things a little more interactive? (not buttons but mouse clicks and stuff) And what is that? Scatter? I was wishing for something like:
draw(circle(radius=20, x=500, y=500, color=:red))
where exactly do I put such a function to loop if I have to time things that way?

These might be dumb questions (I’m pretty new in Julia, been like… 4 days. Although the syntax seems familiar due to python)
Anyways, Thank you so much DUDE!!!

The update loop is in an @async block so you can still do other things at the same time.

For all the other questions, have a look at the docs, for example here:

1 Like

Thank you so very much!