I’m looking to design a program with a fairly specialized drawing feature that I’m hoping some awesome Rustacean has already done the heavy lifting on. This might be an XY problem so I’d be happy to clarify my use case if folks think there might be a totally different way of approaching this.
In short, a user is presented with a blank window. They click two points on the screen and now have two coordinates on a 2D plane. That seems fairly straightforward: the tricky part is that I want to allow a user to be able to connect these two points with a line of variable shape, quite possibly squiggly, and then be able to do some math on the distance between the two points based on the squiggly line.
I’m picturing it like the standard feature in many raster graphics editors like MS Paint or GIMP where you can connect two points with a line and then make said line more or less curvy in multiple places. The particular use case would be to allow someone to essentially trace out a squiggly little route that could be a sort of winding road between our two nodes. Essentially, the program is to offer a basic drawing utility with some extensions (you draw a squiggly line, we tell you what coordinates are on the line and how long it is).
On an abstract level, I would imagine if we needed to implement this from scratch, we could just have a whole bunch of intermediary nodes which are connected by many short, straight lines, but I was hoping there might be an abstraction of that idea already floating around. I’m aware of turtle but the process here is sort of reversed: the mouse draws the line and then the backend computes information about the line (nominally, its length and where it is on the screen).