代码:
<!DOCTYPE html>
<html>
<head>
<title>canvas元素示例</title>
<meta charset="utf-8">
<script type="text/javascript">
function draw(){
var canvas = document.getElementById('canvas');
if (canvas.getContext) {
var context = canvas.getContext('2d');
var path1 = new Path2D();
path1.rect(10,10,100,100);
var path2 = new Path2D();
path2.moveTo(220,60);
path2.arc(170,60,50,0,2*Math.PI,false);
path2.addPath(path1);
context.stroke(path2);
}
}
</script>
</head>
<body onload="draw()">
<h1>canvas元素示例</h1>
<canvas id="canvas" width="400" height="300"></canvas>
</body>
</html>
然后chrome提示:
我这看蒙了也没看出来哪里写错了,求救~
一只甜甜圈
相关分类