+ 1
Canvas text?
How can i put text on a canvas
1 Resposta
+ 1
You can use the `strokeText` and `fillText` methods of a `2DCanvasRenderingContext`.
For example:
```
// assuming there’s a canvas in the DOM with the id “canvas”
const canvas = document.getElementById(“canvas”);
const ctx = canvas.getContext(“2d”);
ctx.fillStyle = “white”; // #ffffff
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = “black”; // #000000
ctx.font = “20px Times New Roman”;
ctx.fillText(“Hello world!”, 10, 10);
ctx.strokeText(“Hello world!”, 10, 30);
```