function formatPercent($subset, $total, $revert = false, $accuracy = 2)
 {
     $v = @round(255 * $subset / $total);
     if ($revert) {
         $v = 255 - $v;
     }
     if ($v < 128) {
         # Red to Yellow
         $red = 'FF';
         $green = sprintf('%02X', 2 * $v);
     } else {
         # Yellow to Green
         $red = sprintf('%02X', 2 * (255 - $v));
         $green = 'FF';
     }
     $blue = '00';
     $color = $red . $green . $blue;
     $percent = statsOutput::formatPercent($subset, $total, $revert, $accuracy);
     return 'bgcolor="#' . $color . '" | ' . $percent;
 }
예제 #2
0
 function formatPercent($subset, $total, $revert = false, $accuracy = 2)
 {
     $v = @round(255 * $subset / $total);
     if ($revert) {
         # Weigh reverse with factor 20 so coloring takes effect more quickly as
         # this option is used solely for reporting 'bad' percentages.
         $v = $v * 20;
         if ($v > 255) {
             $v = 255;
         }
         $v = 255 - $v;
     }
     if ($v < 128) {
         # Red to Yellow
         $red = 'FF';
         $green = sprintf('%02X', 2 * $v);
     } else {
         # Yellow to Green
         $red = sprintf('%02X', 2 * (255 - $v));
         $green = 'FF';
     }
     $blue = '00';
     $color = $red . $green . $blue;
     $percent = parent::formatPercent($subset, $total, $revert, $accuracy);
     return 'bgcolor="#' . $color . '"|' . $percent;
 }