function formatPercent($subset, $total, $revert = false, $accuracy = 2) { MediaWiki\suppressWarnings(); $v = round(255 * $subset / $total); MediaWiki\restoreWarnings(); 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 'style="background-color:#' . $color . ';"|' . $percent; }