我正在使用jQuery Map Hilighter插件,但是我不想在每个区域上淡出一片黑色补丁,而是想要将其反转,而不是使周围区域变暗,从而使悬停区域保持相同的颜色。向jQuery图像地图插件添加反向高亮显示?
我已经看过插件的代码,它似乎使用画布元素(和我猜想的MS)来做突出显示。然而,Firebug是不是很乐于提供确切位置定义形状 - 在演示上面只是显示了这一点:
<canvas style="border: 0pt none ; padding: 0pt; width: 960px; height: 593px; position: absolute; left: 0pt; top: 0pt; opacity: 1;" height="593" width="960"></canvas>
我不能看到任何指定元素形状徘徊。这是出现要被创建形状JS的一部分:
add_shape_to = function(canvas, shape, coords, options) {
var i, context = canvas.getContext('2d');
context.beginPath();
if(shape == 'rect') {
context.rect(coords[0], coords[1], coords[2] - coords[0], coords[3] - coords[1]);
} else if(shape == 'poly') {
context.moveTo(coords[0], coords[1]);
for(i=2; i < coords.length; i+=2) {
context.lineTo(coords[i], coords[i+1]);
}
} else if(shape == 'circ') {
context.arc(coords[0], coords[1], coords[2], 0, Math.PI * 2, false);
}
context.closePath();
if(options.fill) {
context.fillStyle = css3color(options.fillColor, options.fillOpacity);
context.fill();
}
if(options.stroke) {
context.strokeStyle = css3color(options.strokeColor, options.strokeOpacity);
context.lineWidth = options.strokeWidth;
context.stroke();
}
if(options.fade) {
fader(canvas, 0);
}
};
嗨,谢谢你的回应。我已经实现了你所说的,它似乎适用于某些多边形区域 - 我假设其他人都倒退了,所以我会尽快对其进行排序。但是,我无法用圆形元素来解决它。有任何想法吗? – DisgruntledGoat 2009-11-24 21:33:38