Get coordinates from character on the canvas
Hello :)
I am trying to get the coordinates of a character shown on a canvas. The experiment displays a line sentence that varies in length every time a new one is shown on the canvas. So, is there any precise way to get the (x, y) coordinates of the last character?
I have implemented an estimation that multiplies the size of a character by the length of the sentence (number of characters). However, on some occasions, it is not precise enough.
Any solutions?
Comments
Hi @blancasanmi ,
Have you seen this functionality: https://osdoc.cogsci.nl/4.0/manual/python/canvas/#text_sizetext-centertrue-max_widthnone-style_args
This should give you width and height of your text. Together with the starting position you should be able to compute the coordinates of the last character rather accurately.
Eduard