I have a big project that shows movement of objects. I draw many of shapes according to each other but this one is little bit tricky for me. I spent many days to achieve it but I couldn't draw it correctly. If anyone shows me a small demo, I can do the rest by myself.
I have a line with 2 endpoints. (x1,y1) and (x2,y2) s.t. all 4 parameters may dynamically change with the condition y2 is always greater than y1. In other words, endpoint of the line is always pointing down. I need to slide a rectangle with the given width and height on the drawn line. Sliding position on the angled line is also given by the user. Let's call it as position. Position 0 point is where the left corner of the rectangle touches x1,y1 in the below picture. I drew what I explained above. There are total 7 parameters bolted above.
Sliding rectangle must be always at the right side of the drawn line.
Total, there could be 3 cases. 2 of them are shown above, and I didn't draw vertical line case where x1=x2 since it's quite easy to imagine how it is going to look like.
If anyone shows me how to do it in Tkinter, I would be very appreciated.
Thanks in advance!


The code block below does what I asked above.