canvas isPointInPath()方法 画布交互
var event=event||window.event;
var sx=event.offsetX;
var sy=event.offsetY;
for(var i=0;i<bal.length;i++){
context.beginPath(); //一定要beginPath才行 fill从beginPath开始
context.arc(bal[i].x,bal[i].y,bal[i].r,0,Math.PI*2); //如果没有fill()就不会画出来
if(context.isPointInPath(sx,sy){
context.fillStyle="rgba(255,0,0,0.6)";
context.fill();
}
}
}
判断鼠标的位置在不在圆中