X-Git-Url: http://git.archive.openwrt.org/?a=blobdiff_plain;f=applications%2Fluci-statistics%2Fluasrc%2Fstatistics%2Frrdtool%2Fcolors.lua;fp=applications%2Fluci-statistics%2Fluasrc%2Fstatistics%2Frrdtool%2Fcolors.lua;h=0000000000000000000000000000000000000000;hb=1bb4822dca6113f73e3bc89e2acf15935e6f8e92;hp=2da9f5a08a3742fb3a16823c90734220f53e2b88;hpb=9edd0e46c3f880727738ce8ca6ff1c8b85f99ef4;p=project%2Fluci.git diff --git a/applications/luci-statistics/luasrc/statistics/rrdtool/colors.lua b/applications/luci-statistics/luasrc/statistics/rrdtool/colors.lua deleted file mode 100644 index 2da9f5a08..000000000 --- a/applications/luci-statistics/luasrc/statistics/rrdtool/colors.lua +++ /dev/null @@ -1,73 +0,0 @@ ---[[ - -Luci statistics - diagram color helper class -(c) 2008 Freifunk Leipzig / Jo-Philipp Wich - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ - -]]-- - -module("luci.statistics.rrdtool.colors", package.seeall) - -require("luci.util") - - -Instance = luci.util.class() - -function Instance.from_string( self, s ) - return { - tonumber(s:sub(1,2), 16), - tonumber(s:sub(3,4), 16), - tonumber(s:sub(5,6), 16) - } -end - -function Instance.to_string( self, c ) - return string.format( - "%02x%02x%02x", - math.floor(c[1]), - math.floor(c[2]), - math.floor(c[3]) - ) -end - -function Instance.random( self ) - local r = math.random(255) - local g = math.random(255) - local min = 0 - local max = 255 - - if ( r + g ) < 255 then - min = 255 - r - g - else - max = 511 - r - g - end - - local b = min + math.floor( math.random() * ( max - min ) ) - - return { r, g, b } -end - -function Instance.faded( self, fg, opts ) - opts = opts or {} - opts.background = opts.background or { 255, 255, 255 } - opts.alpha = opts.alpha or 0.25 - - if type(opts.background) == "string" then - opts.background = _string_to_color(opts.background) - end - - local bg = opts.background - - return { - ( opts.alpha * fg[1] ) + ( ( 1.0 - opts.alpha ) * bg[1] ), - ( opts.alpha * fg[2] ) + ( ( 1.0 - opts.alpha ) * bg[2] ), - ( opts.alpha * fg[3] ) + ( ( 1.0 - opts.alpha ) * bg[3] ) - } -end