Skip to content

Commit

Permalink
提交
Browse files Browse the repository at this point in the history
  • Loading branch information
gjmhandsome committed Jun 17, 2018
1 parent df55045 commit 61af421
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions canvas.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<canvas id="canvas" width="500" height="500"></canvas>
</body>
<script type="text/javascript">
var canvas = document.getElementById('canvas');
var c = canvas.getContext('2d');


var points = [];

var point = function(x,r,v){
this.x = x;
this.r = r;
this.v = v;
}

for (var i = 0 ; i < 10 ; i++) {
points.push( new point(Math.random()*10,Math.random()*10+10,Math.random()*3+2) )
}

var drawCircle = function(){

canvas.width = canvas.width;
c.fillStyle = '#ff6700';
c.beginPath();
for (var i = 0 ; i < points.length ;i++) {
c.arc(points[i].x,130,points[i].r,0,2*Math.PI,true);
if(points[i].x > 500) {
points[i].x = 0;
} else {
points[i].x = points[i].x + points[i].v;
}

}

c.closePath();
c.fill();


}

setInterval(drawCircle,17);


</script>
</html>

0 comments on commit 61af421

Please sign in to comment.