soundprojects / trainsim

Train simulator written in Rust
1 stars 0 forks source link

Draw a train track #5

Closed soundprojects closed 2 years ago

soundprojects commented 2 years ago

We can use Slint's Path objects to draw a route. API is pretty straightforward and we can use relative sizing using the parent objects.

Path's allow thickness and colors. We can either draw some track for now or we can dynamically build one from a data structure which abstracts the track. Something like PetGraph to specify what we want and then some function to turn this into a vector of Path objects.

soundprojects commented 2 years ago

Created track and section structures. Will create a function in either .slint or in rust to create a vector of Path's that can be drawn in the UI.

I guess that going through our track structure and simply drawing a path for each section should work. This would allow us to color the section properly if it is active.

soundprojects commented 2 years ago

Drawing works using our slint structures in a for loop. Not the most pretty thing to convert between UI and own structs but fine for now. Drawing can be expanded to make it adjust to widths and make it more pretty