<canvas id=canvas width=500 height=400 style=background-color: yellow;></canvas>
代碼如下:
var canvas=document.getelementbyid(canvas);
var cxt=canvas.getcontext(2d);
cxt.font=40px 黑體;
//繪制實心字
cxt.fillstyle=red;//填充紅色
cxt.filltext(hello,思思博士,10,50);
//繪制空心字
cxt.strokestyle=red;//紅色邊
cxt.stroketext(hello,思思博士,10,100);
更多信息請查看IT技術(shù)專欄