private function getColor(WaterlineCell $cell) { if (!$cell->isWater()) { $r = (int) round($cell->percentFromMax * 200); $g = 200 - (int) round($cell->percentFromMax * 75); return imagecolorallocate($this->map->getVisualiser()->getImageResource(), $r, $g, 30); } else { $ratio = $cell->percentFromMax > 1 ? 1 : $cell->percentFromMax; $c = (int) round(240 - $ratio * 240); $b = 255; return imagecolorallocate($this->map->getVisualiser()->getImageResource(), $c, $c, $b); } }
/** * Определение цвета точки, в зависимости от высоты над уровнем воды * * @param WaterlineCell $cell * * @return string */ private static function getColor(WaterlineCell $cell) { if (!$cell->isWater()) { $r = dechex(round($cell->percentFromMax * 12)); $g = dechex(12 - round($cell->percentFromMax * 5)); $color = $r . $g . '2'; } else { $ratio = $cell->percentFromMax > 1 ? 1 : $cell->percentFromMax; $c = dechex((int) round(14 - $ratio * 14)); $b = 'f'; $color = $c . $c . $b; } return $color; }