Where to start with interactive 2d display

This may be a little general for this forum but hoping there will be some folks here with some good pointers!

As part of a proof of concept for using Rust in a project, I want to create the following:

  • A 2D image generated from a data set.
  • An overlay on that image based on some analysis configuration. It would be a relatively simple pair of concentric circles.
  • The ability to click on the overlay and drag them around.
  • Make this a component that could be part of a larger UI. Technology TBC.

Previously I've worked in environments with a full UI framework, and not sure where to start.

Would you use the 2D rendering components from a game engine like Piston or Bevy?

Are there UI frameworks that would make this simpler?

I think the input requirements would mean it would need to be more advanced than something like WGPU but I could be wrong!

Any other obvious starting places I'm missing?

Yeah would be interesting for me too. Been looking into game engines and Web-GPU too. Looks like some data science project?

Yeah sort of. I work on measurement systems so this is visualisation for a particle detector.

Glad to hear I'm not the only one looking at this with confusion!

Looks like plotters has a good set of backend options provided I can find a way to do the input. I guess that will come from the backend itself

Hi! So, I'm a bit biased in my opinion on this topic, but I'll gladly share what I think.

For starters, the GUI options in Rust are all over the place. You can see some examples at Are we GUI yet? and I have tried many of these over several different projects with various goals. I think I would personally weigh my options between these two:

  1. Tauri if you really want to create a web-based desktop or mobile app. Emphasis on web-based. Developers who will naturally migrate to this kind of stack are probably those familiar with Electron, and who (for reasons) are tied to React or whatever big SPA frameworks are popular on this day of the month.

  2. egui is a good choice for developers who are more interested in developing an application that operates internally like a game. You have the full power of a GPU at your fingertips if that's what you really want. The selection of built-in widgets is fairly complete, including a plot widget that can even do fancy real time animations.

In full disclosure, I'm a game developer so my immediate choice is egui, even for desktop applications that are decidedly not games. I don't intend to compare and contrast the immediate mode vs retained mode GUI architectures, but I do believe that immediate mode wins out (with the added compromise that a mixture of the two philosophies is actually not all that bad, and definitely an improvement over purely retained mode).

I started to make another application using egui recently, and it always feels very nice (and right at home) to use it. You have a choice of backends, but my go to is egui-wgpu. Not that it really matters, because almost all of the graphics layer is abstracted away.

bevy is awesome, too, but for quite different reasons. I haven't used its GUI implementation, nor any of the available replacements. What bevy excels at is its incredible ECS that makes managing data extremely flexible. That said, I haven't found a single application design that I would ever need ECS for. The kinds of problems it solves are of the variety "this whatchamacallit is like that doohickey except it can also dingbat, but it can't florb like the doohickey can". Which is very much unlike any data flow in any application I know of (assuming it's a user-facing application with a GUI for humans to manipulate some data; you can always contrive an example where weird data flows make sense for non-human consumption).

Anyway, you can check out the egui demo app in your browser at https://www.egui.rs/#demo. Maybe it will fit your needs, too?

Note: egui also has multi-touch support and that may come in very handy with interactive display.


1 Like

Thanks to everyone for the response. That really helps to narrow the field!

I'm going to have a play with egui and see if I can get something basic working

If you want a more Lego brick approach,

Winit is the stock way to get a window and event loop in Rust (though glazier might be a better choice for applications later)

Piet is a long standing and stable, pretty slick canvas-like rendering API, which sounds like a good match for what you're talking about here.

If you want a proper application widget toolkit, things get a bit messier. Egui is very simple to use, and will get you going quick, but I found it very hard to make it do exactly what I wanted.

Druid, Iced, and so on in the other "pure rust" toolkits are interesting but still very experimental for now (Iced got picked by Pop! OS for their next desktop UI though, so it's probably going to get productionized relatively quickly)

Tauri is a very complete system, with only a few rough edges, and is probably the best pick right now to build a shipping program, given the well developed HTML user interface ecosystem. Tauri also has a very complete OS integration: including packaging, self update, and platform API access, including implementing custom backend behavior in Rust quite simply.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.