Metóda strokeText
Metóda strokeText kreslí obrys textu
na canvas. Prvým parametrom prijíma text
pre kreslenie, a druhým a tretím - súradnice
tohto textu na plátne canvasu. Veľkosť a
typ písma sú nastavené pomocou vlastnosti font.
Syntax
kontext.strokeRect(text, x, y);
Príklad
Poďme nakresliť obrys textu pomocou
strokeRect, nastavením veľkosti na 30px
a 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);
: