WmTimer関数に処理を移動。
だいたい30FPSになるように setInterval を回す
内部カウンタを追加して画面に表示。
"use strict";
const FONT = "48px monospace"; //使用フォント
let gFrame = 0; //内部カウンタ
//タイマーイベント発生時の処理
function WmTimer()
{
gFrame++; //内部カウンタを加算
const ca = document.getElementById("main"); //mainキャンバスの要素を取得
const g = ca.getContext("2d"); //2D描画コンテキストを取得
g.font = FONT; //文字フォントを設定
g.fillText("Hello World" + gFrame, 0, 64);
}
//ブラウザ起動イベント
window.onload = function(){
setInterval( function() { WmTimer() }, 33); //33ms間隔で WmTimer() を呼び出すように指示 1000/33 = 30FPS
}