标签:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>初学html5</title>
<meta name="keywords" content="">
<meta name="description" content="">
<script src="canvas.js"></script>
</head>
<body onload="draw(‘canvas‘);">
<canvas id="canvas" width="500" height="350"></canvas>
</body>
</html>
js如下:
function draw(id)
{
var canvas=document.getElementById(id);
var context=canvas.getContext(‘2d‘);
context.fillStyle=‘#ccc‘;
context.fillRect(0,0,400,300);
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="rgba(255,0,0,0.25)";
context.fill();
context.strokeStyle="red";
context.stroke();
}
}
标签:
原文地址:http://www.cnblogs.com/ll-taj/p/5292948.html