$im = imagecreate($imageSize, $imageSize); $i = 0; for ($x = $startX; $x <= $endX; $x++) { $j = 0; for ($y = $startY; $y <= $endY; $y++) { // Check for building if (isset($buildings[$x]) && isset($buildings[$x][$y])) { $color = color_cache($im, $buildings[$x][$y][0]->getMapColor()); } else { $location = Dolumar_Map_Location::getLocation($x, $y); $c = $location->getHeightIntencity(); $col = $location->getMapColor(); $col[0] = floor($col[0] * $c); $col[1] = floor($col[1] * $c); $col[2] = floor($col[2] * $c); $color = color_cache($im, $col); } imagerectangle($im, $i, $j, $i + 1, $j + 1, $color); $j++; } $i++; } imagepng($im, $file); imagepng($im); } } else { // Get HTML $parts = MAXMAPSTRAAL / $imageSize; for ($i = -$parts; $i < $parts; $i++) { for ($j = -$parts; $j < $parts; $j++) { $file = 'cache/hugemap/map' . $i . 'p' . $j . '.png';
function getBackgroundImage($x, $y, $tilesToLoad, $usecache = true) { global $color_cache; $cachename = 'i' . intval($_GET['x']) . 'p' . intval($_GET['y']) . $tilesToLoad . '.png'; $cache = Neuron_Core_Cache::__getInstance('minimapbg/'); if ($usecache && $cache->hasCache($cachename, 0)) { $img = $cache->getFileName($cachename); return imagecreatefrompng($img); } else { $color_cache = array(); // Build the new background image. $tileSizeX = 8; $tileSizeY = $tileSizeX / 2; $halfTileX = floor($tileSizeX / 2); $halfTileY = floor($tileSizeY / 2); $im = imagecreate($tileSizeX * $tilesToLoad, $tileSizeY * $tilesToLoad); $background = imagecolorallocate($im, 0, 0, 0); $switchpoint = $tilesToLoad; $loadExtra = 1; $startX = ($x + $y) * $switchpoint; $startY = ($x - $y) * $switchpoint; for ($i = 0 - $loadExtra - 1; $i < $switchpoint * 2 + $loadExtra + 1; $i++) { if ($i > $switchpoint) { $offset = ($i - $switchpoint) * 2; } else { $offset = 0; } $colStart = 0 - $i + $offset - $loadExtra; $colEnd = $i - $offset + $loadExtra + 1; //$output['sq'][$sQ]['tl'][$i] = array (); $tx = $startX + $i; $white = imagecolorallocate($im, 255, 255, 255); for ($j = $colStart - 1; $j < $colEnd + 1; $j++) { $ty = $startY - $j; $px = round(($i - $j) * floor($tileSizeX / 2)); $py = round(($i + $j) * floor($tileSizeY / 2)); // Check for building /* if (isset ($buildings[$tx]) && isset ($buildings[$tx][$ty])) { $color = color_cache ($im, $buildings[$tx][$ty][0]->getMapColor ()); } else { */ $location = Dolumar_Map_Location::getLocation($tx, $ty); $c = $location->getHeightIntencity(); $col = $location->getMapColor(); $col[0] = floor($col[0] * $c); $col[1] = floor($col[1] * $c); $col[2] = floor($col[2] * $c); $color = color_cache($im, $col); //} $punten = array($px + $halfTileX, $py, $px + $tileSizeX, $py + $halfTileY, $px + $halfTileX, $py + $tileSizeY, $px, $py + $halfTileY); imagefilledpolygon($im, $punten, 4, $color); } } ob_start(); imagepng($im, null); $cache->setCache($cachename, ob_get_clean()); return $im; } }