1 module("luci.statistics.rrdtool.colors", package.seeall)
7 Instance = luci.util.class()
9 function Instance.from_string( self, s )
11 luci.bits.Hex2Dec(s:sub(1,2)),
12 luci.bits.Hex2Dec(s:sub(3,4)),
13 luci.bits.Hex2Dec(s:sub(5,6))
17 function Instance.to_string( self, c )
26 function Instance.random( self )
27 local r = math.random(255)
28 local g = math.random(255)
32 if ( r + g ) < 255 then
38 local b = min + math.floor( math.random() * ( max - min ) )
43 function Instance.faded( self, fg, opts )
45 opts.background = opts.background or { 255, 255, 255 }
46 opts.alpha = opts.alpha or 0.25
48 if type(opts.background) == "string" then
49 opts.background = _string_to_color(opts.background)
52 local bg = opts.background
55 ( opts.alpha * fg[1] ) + ( ( 1.0 - opts.alpha ) * bg[1] ),
56 ( opts.alpha * fg[2] ) + ( ( 1.0 - opts.alpha ) * bg[2] ),
57 ( opts.alpha * fg[3] ) + ( ( 1.0 - opts.alpha ) * bg[3] )