What are some efficient methods of finding the x,y coordinates of the right and bottom edges of a paragraph of text placed on a canvas element? So far attempts to multiply number of characters times font size have proved unreliable and more difficult than expected.
For example:
var canvas = document.getElementById("myCanvas");
var ctx = canvas.getContext("2d");
ctx.font = "30px Arial";
ctx.fillText("Hello World, this is a sentence", 10, 50);
I'd like to find the exact location of the bottom right corner of the sentence placed on canvas without having to calculate it dynamically based on the font size.
tag then use css on that tag, or just change the background color of the css on the p tag
– devin Oct 24 '22 at 16:39tags.
– Schuyler Sloane Oct 24 '22 at 16:44