HTML5画矩形
1、源码
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>HTML5画矩形</title>
<script>
function draw(id)
{
var canvas = document.getElementById("canvas");
if(canvas == null)
{
return false;
}
var context = canvas.getContext("2d");
context.fillStyle = "#FF00000";
context.fillRect(0,0,500,600);
for(var i=0;i<10;i++)
{
context.beginPath();
context.arc(i*25,i*25,i*10,0,Math.PI*2,true);
context.closePath();
context.fillStyle = "#00FF00";
context.fill();
}
}
</script>
</head>
<body onLoad="draw('canvas')">
<canvas id="canvas" width="500px" height="600px"></canvas>
</body>
</html>
2、结果