没有办法告诉你鼠标在一个透明的圆形像素上:你必须检查房子是否与实际的圆形相交(是的,真的)。实际上,这是一个很明显的信号。考虑到你的循环“是对你的边缘”的旋转(这些都是不可能的),你必须检查房子的光标。或者是圆的半径(宽度为/2):
function intersectsCircle(diameter, center, mousePosition)
{
var radius = diameter / 2;
// compute the distance between mousePosition and center
var deltaX = mousePosition.x - center.x;
var deltaY = mousePosition.y - center.y;
return Math.sqrt(deltaX * deltaX + deltaY * deltaY) < radius;
}
160; 160194160194160\160194160160194160\160160194160160194160\194\\160;\\\194\160160\194\160\160\160\194\\\160160160160活动部分:
function intersects(target, event)
{
var center = {x: target.x + target.width / 2, y: target.y + target.height / 2};
var mousePosition = {x: event.clientX, y: event.clientY};
if(intersectsCircle(target.width, center, mousePosition))
alert('Foo');
}
<img onmouseover="intersects(this, event)" src="circle.png" />