我正在使用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