-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo10.html
42 lines (39 loc) · 1.3 KB
/
demo10.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>canvas</title>
<meta name="description" content="">
<meta name="keywords" content="">
<link href="" rel="stylesheet">
<script type="text/javascript" src="js/jquery-2.1.4.min.js"></script>
</head>
<body>
<canvas id="canvas" style="border:1px solid #ccc; margin: 50px auto;display: block;" height="768" width="1024">
如果浏览器不支持canvas的话则会显示这行文字
</canvas>
<script type="text/javascript">
window.onload= function(){
var canvas = document.getElementById("canvas");
var canvastext = canvas.getContext("2d");
// canvastext.lineWidth = 5;
// canvastext.strokeStyle = "#abc";
canvastext.fillStyle = "#abcdef";
var y = 0;
var x = 0;
// arc() 总共有6个参数 1 2 是圆心坐标 3 是半径 4 5 弧线的开始以及结束点 最后一个是可选参数 默认的是false顺时针,true的话就是逆时针
setInterval(function(){
x = Math.random()*100;
y = Math.random()*100;
canvastext.beginPath()
canvastext.clearRect(0, 0, canvas.width, canvas.height); // 清空
canvastext.arc(x+200,y+200,50,0,2*Math.PI)
canvastext.closePath();
canvastext.fill();
// canvastext.stroke();
},200)
}
</script>
</body>
</html>