-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo17.html
37 lines (36 loc) · 991 Bytes
/
demo17.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
<!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>
<h1>drawImage</h1>
<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");
var x = 0;
setInterval(function(){
x +=5;
canvastext.beginPath();
canvastext.clearRect(0,0,canvas.width,canvas.height);
canvastext.arc(x,100,10,0,20)
canvastext.closePath();
canvastext.fill();
if(x>canvas.width){
x=0;
}
},100)
}
</script>
</body>
</html>