【发布时间】:2011-01-05 11:24:29
【问题描述】:
给定以毫秒为单位的 ping,是否有任何方法可以通过算法计算出阴影,我们可以在不硬编码 if 和颜色的情况下进行此 ping? IE这个功能很好用:
function displayPing(lngThePingTime)
response.Write("<span style=""font-wight:bold;color:")
if(lngThePingTime < 50) then
response.Write("#77ff66")
elseif lngThePingTime < 100 then
response.Write("#22ee00")
elseif lngThePingTime < 150 then
response.Write("#33bb00")
elseif lngThePingTime < 250 then
response.Write("#ffaa00")
elseif lngThePingTime < 400 then
response.Write("#ee6600")
elseif lngThePingTime < 550 then
response.Write("#dd4400")
elseif lngThePingTime < 700 then
response.Write("#dd1100")
elseif lngThePingTime < 1000 then
response.Write("#990000")
else
response.Write("#660000")
end if
response.Write(""">")
response.Write lngThePingTime
response.Write("</span>")
end function
但是有没有办法让算法说:
Lowest Colour : #77ff66
Highest Colour: #660000
Cutoff Value: 1500 (any ping higher than this is fixed to highest colour)
所以颜色将是每个阴影而不是一组固定的阴影?
语言无所谓,方法更感兴趣!
【问题讨论】:
-
将颜色拆分为相应的 RGB 值,并在 Low 和 High 之间进行简单的线性插值。看起来不错,我用过这个。
-
HSV 坐标中的插值通常看起来更好一些,即从绿色到红色的过渡通过黄色而不是褐色。