Answers for "how to center text in canvas js"

3

javascript canvas text centered

var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.textAlign = "start"; // left/right depending on language
ctx.textAlign = "end"; // left/right depending on language
ctx.textAlign = "left";
ctx.textAlign = "center";
ctx.textAlign = "right";
ctx.fillText("my text!", 150, 140);
Posted by: Guest on March-02-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language