diff options
author | root <root@frank.tg14.gathering.org> | 2014-04-18 02:11:46 +0200 |
---|---|---|
committer | root <root@frank.tg14.gathering.org> | 2014-04-18 02:11:46 +0200 |
commit | e49afdb47122a2e94219a73d617f077467487441 (patch) | |
tree | 2be05ddb5c1010812fff852823265a77df3cfc12 | |
parent | b171dcf084ca6a04351cf8b338c6882bda869547 (diff) |
Add red colors.
-rw-r--r-- | web/nms.gathering.org/ping.js | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/web/nms.gathering.org/ping.js b/web/nms.gathering.org/ping.js index 73aced3..cdcfdd1 100644 --- a/web/nms.gathering.org/ping.js +++ b/web/nms.gathering.org/ping.js @@ -128,11 +128,18 @@ function rgb_from_latency(latency_ms) { // 10ms is max var l = latency_ms / 10.0; - if (l >= 1.0) { l = 1.0; } - l = Math.pow(l, 1.0/2.2); - l = Math.round(l * 255.0); - - return 'rgb(' + l + ', 255, 0)'; + if (l >= 2.0) { + return 'rgb(255, 0, 0)'; + } else if (l >= 1.0) { + l = 2.0 - l; + l = Math.pow(l, 1.0/2.2); + l = Math.round(l * 255.0); + return 'rgb(255, ' + l + ', 0)'; + } else { + l = Math.pow(l, 1.0/2.2); + l = Math.round(l * 255.0); + return 'rgb(' + l + ', 255, 0)'; + } } function really_update_ping(json) { |