HTM5 Canvas 会回弹的球
应该叫啥?屏幕环绕 */ /*--> */ // 获取舞台 var canvas=document.getElementById("stage"); // 绘图接口 var context=canvas.getContext("2d"); // 中心点位置 var centerX=canvas.width/2; var centerY=canvas.height/2; // 运动的球 var ball= function (x,y,vx,vy,radius,color) { this .x=x; this .y=y; this .vx=vx; this .vy=vy; this .radius=radius; this .color=color; // 绘制球 this .draw= function () { context.beginPath(); context.strokeStyle = this .color; context.fillStyle = this .color; context.lineWidth = 2; context.arc( this .x, this .y, this .radius, 0, 2 * Math.PI, false ); context.fill(); context.stroke(); context.closePath(); }