So I have this code that displays a string, and whenever the mouse hovers over it, then it changes colour.
if (mouseX > 40 && mouseX < text.length() * 17)
fill(0);
The text size is 25. However, it seems that text.length() * 17
only works for some strings. On shorter strings, you have to move your mouse closer, and on longer strings, you have to move your mouse further.
So is there a way that I can use a string’s length to set boundaries to the string? Thanks