private static function sumColors($axis, $histo, $vBox)
{
$total = 0;
$partialSum = array();
// The selected axis should be the first range
$colorIterateOrder = array_diff(array('r', 'g', 'b'), array($axis));
array_unshift($colorIterateOrder, $axis);
// Retrieves iteration ranges
list($firstRange, $secondRange, $thirdRange) = static::getVBoxColorRanges($vBox, $colorIterateOrder);
foreach ($firstRange as $firstColor) {
$sum = 0;
foreach ($secondRange as $secondColor) {
foreach ($thirdRange as $thirdColor) {
list($red, $green, $blue) = static::rearrangeColors($colorIterateOrder, $firstColor, $secondColor, $thirdColor);
$index = static::getColorIndex($red, $green, $blue);
if (isset($histo[$index])) {
$sum += $histo[$index];
}
}
}
$total += $sum;
$partialSum[$firstColor] = $total;
}
return array($total, $partialSum);
}