我在這裏創辦了這一段代碼堆棧:JAVASCRIPT亮度功能 - 降低
function increase_brightness(hex, percent){
var r = parseInt(hex.substr(1, 2), 16),
g = parseInt(hex.substr(3, 2), 16),
b = parseInt(hex.substr(5, 2), 16);
return '#' +
((0|(1<<8) + r + (256 - r) * percent/100).toString(16)).substr(1) +
((0|(1<<8) + g + (256 - g) * percent/100).toString(16)).substr(1) +
((0|(1<<8) + b + (256 - b) * percent/100).toString(16)).substr(1);
}
沒有人知道如何使完全相同逆?
功能decreas_brightness(){}
我的意思是
你試過嗎? – azendh
試過它不起作用 – sbaaaang
該函數不適用於所有情況。 'increase_brightness('#777777',100)':輸出是#000000 – azendh