From 68e4596b4036ed28da8e4efe9d0b422bd6cba5cf Mon Sep 17 00:00:00 2001 From: kanoi Date: Thu, 6 Aug 2015 13:40:32 +1000 Subject: [PATCH] php - add colour to CDF[Erl] --- pool/page_blocks.php | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/pool/page_blocks.php b/pool/page_blocks.php index 706e3a78..bce95e0e 100644 --- a/pool/page_blocks.php +++ b/pool/page_blocks.php @@ -1,5 +1,36 @@ 255) + $grn = 255; + + if ($grn > 190) + $fg = 'blue'; + else + $fg = 'white'; + $bg = sprintf("#00%02x00", $grn); + } + else # ($erl > 0.5) + { + $ref = (-0.3 - log10(1.0 - $erl)) * 255; + if ($red < 0) + $red = 0; + if ($red > 255) + $red = 255; + + $fg = 'white'; + $bg = sprintf("#%02x0000", $red); + } + + return array($fg, $bg); +} +# function pctcolour($pct) { if ($pct == 100) @@ -79,14 +110,19 @@ function doblocks($data, $user) $desc = $ans['s_desc:'.$i]; $diff = number_format(100 * $ans['s_diffratio:'.$i], 2); $mean = number_format(100 * $ans['s_diffmean:'.$i], 2); - $cdferl = number_format($ans['s_cdferl:'.$i], 4); + + $cdferl = $ans['s_cdferl:'.$i]; + list($fg, $bg) = erlcolour($cdferl); + $cdferldsp = "".number_format($cdferl, 4).''; + $bg = " bgcolor=$bg"; + $luck = number_format(100 * $ans['s_luck:'.$i], 2); $pg .= ""; $pg .= "$desc Blocks"; $pg .= "$diff%"; $pg .= "$mean%"; - $pg .= "$cdferl"; + $pg .= "$cdferldsp"; $pg .= "$luck%"; $pg .= "\n"; }