HTML5のキャンバスに円を描画します。
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>
<title>円の描画</title>
<script type="text/javascript">
/*
ページロード完了
*/
function OnLoad() {
// キャンバス取得
var canvas = document.getElementById("canvas");
// キャンバスの幅と高さを取得
var width = canvas.getAttribute("width");
var height = canvas.getAttribute("height");
// ログ
console.log("width = " + width);
console.log("height = " + height);
// キャンバスへ描画
var context = canvas.getContext('2d');
context.beginPath();
context.fillStyle = 'white';
context.fillRect(0, 0, width, height);
context.beginPath();
context.fillStyle = 'red';
context.arc(width / 2, height / 2, height / 3, 0, Math.PI * 2, false);
context.fill();
}
</script>
</head>
<body bgcolor="#c0c0ff" onload="OnLoad()">
<h1>円の描画</h1>
<canvas width="300" height="200" id="canvas" style="background-color:black;"></canvas>
<br/>
<a href="../html5_list.html">戻る</a>
</body>
</html>