array(ROOM1, ROOM1, ROOM1, PATH, FREE, FREE, FREE), 1 => array(ROOM1, ROOM1, ROOM1, PATH, FREE, FREE, FREE), 2 => array(FREE, FREE, PATH, PATH, FREE, FREE, FREE), 3 => array(FREE, ROOM2, ROOM2, PATH, PATH, FREE, FREE), 4 => array(FREE, ROOM2, ROOM2, FREE, PATH, FREE, FREE), 5 => array(FREE, ROOM2, ROOM2, FREE, PATH, FREE, FREE), 6 => array(FREE, FREE, FREE, PATH, PATH, ROOM3, ROOM3), 7 => array(FREE, FREE, FREE, PATH, FREE, ROOM3, ROOM3) ); $image = imagecreatetruecolor(MAP_WIDTH * BLOCK_SIZE, MAP_HEIGHT * BLOCK_SIZE); $colors = array(); $colors['room'] = imagecolorallocate( $image, hexdec(substr(COLOR_ROOM, 0, 2)), hexdec(substr(COLOR_ROOM, 2, 2)), hexdec(substr(COLOR_ROOM, 4, 2))); $colors['path'] = imagecolorallocate( $image, hexdec(substr(COLOR_PATH, 0, 2)), hexdec(substr(COLOR_PATH, 2, 2)), hexdec(substr(COLOR_PATH, 4, 2))); $colors['free'] = imagecolorallocate( $image, hexdec(substr(COLOR_FREE, 0, 2)), hexdec(substr(COLOR_FREE, 2, 2)), hexdec(substr(COLOR_FREE, 4, 2))); $colors['line'] = imagecolorallocate( $image, hexdec(substr(COLOR_LINE, 0, 2)), hexdec(substr(COLOR_LINE, 2, 2)), hexdec(substr(COLOR_LINE, 4, 2))); for($i = 0; $i < MAP_WIDTH; $i++) { for($j = 0; $j < MAP_HEIGHT; $j++) { switch($map[$i][$j]) { case FREE: $c = $colors['free']; break; case PATH: $c = $colors['path']; break; default: $c = $colors['room']; break; } imagefilledrectangle($image, $i*BLOCK_SIZE, $j*BLOCK_SIZE, ($i+1) * BLOCK_SIZE, ($j+1) * BLOCK_SIZE, $c); if(isset($map[$i][$j-1]) && $map[$i][$j-1] != $map[$i][$j]) { imagefilledrectangle($image, $i*BLOCK_SIZE, $j*BLOCK_SIZE, ($i+1) * BLOCK_SIZE, $j*BLOCK_SIZE, $colors['line']); } if(isset($map[$i-1][$j]) && $map[$i-1][$j] != $map[$i][$j]) { imagefilledrectangle($image, $i*BLOCK_SIZE, $j*BLOCK_SIZE, $i * BLOCK_SIZE, ($j+1)*BLOCK_SIZE, $colors['line']); } } } imagerectangle($image, 0, 0, MAP_WIDTH*BLOCK_SIZE -1, MAP_HEIGHT*BLOCK_SIZE -1, $colors['line']); header("Content-type: image/png"); imagepng($image); die();