Metoda strokeText
Metoda strokeText rysuje kontur tekstu
na canvas. Pierwszym parametrem przyjmuje tekst
do narysowania, a drugim i trzecim - współrzędne
tego tekstu na płótnie kanwy. Rozmiar i
typ czcionki są ustawiane za pomocą właściwości font.
Składnia
kontekst.strokeRect(tekst, x, y);
Przykład
Narysujmy kontur tekstu za pomocą
strokeRect, ustawiając rozmiar na 30px
i typ Arial:
<canvas id="canvas" width="200" height="200" style="background: #f4f4f4;"></canvas>
let canvas = document.querySelector('#canvas');
let ctx = canvas.getContext('2d');
ctx.font = '30px Arial';
ctx.strokeText('Hello world', 30, 50);
: