「javascript」strokeText()でテキストを塗りつぶすサンプル

書式
strokeText(text, x, y [, maxWidth])
text:描画するテキストを指定
x:横方向の座標
y:縦方向の座標
使用例
1.htmlコード

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<div id="kk">
<canvas id="cs" width="400" height="150"></canvas>
</div>
<div id="kk"> <canvas id="cs" width="400" height="150"></canvas> </div>
<div id="kk">
    <canvas id="cs" width="400" height="150"></canvas>
</div>

2.JSコード

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
const ct = document.getElementById("cs");
const ctx = ct.getContext("2d");
ctx.strokeText("test sample", 0, 25);
const ct = document.getElementById("cs"); const ctx = ct.getContext("2d"); ctx.strokeText("test sample", 0, 25);
const ct = document.getElementById("cs");
const ctx = ct.getContext("2d");

ctx.strokeText("test sample", 0, 25);

 

JavaScript

Posted by arkgame