= -20 && $_POST['distance'] <= 40) ? $_POST['distance'] : 15; $stagger = (isset($_POST['stagger']) && is_numeric($_POST['stagger']) && $_POST['stagger'] >= 0 && $_POST['stagger'] <= 20) ? $_POST['stagger'] : 0; #separate into individual letters $msg = preg_split('//', $_POST['text'], 30, PREG_SPLIT_NO_EMPTY); foreach ($msg as &$m) { $m = ord($m); if (!file_exists("$styledir$m$ext")) { $m = $replacement; } $ary = getimagesize("$styledir$m$ext"); if ($height < ($ary[1] + ($stagger * 2))) { $height = $ary[1] + ($stagger * 2); } } if ($direction == "left") { $msg = array_reverse($msg); } #build the piece $wall = imagecreatetruecolor($distance, $height); foreach ($msg as $letter) { $next = imagecreatefrompng("$styledir$letter$ext"); $width = imagesx($wall) + imagesx($next) - $distance; $temp = imagecreatetruecolor($width, $height); if ($direction == "right") { imagecopy( $temp , $wall , 0, ($height-imagesy($wall))/2 , 0 , 0 , imagesx($wall) , imagesy($wall) ); imagecopy( $temp , $next , imagesx($temp)-imagesx($next) , (intval(($height-imagesy($next))/2) + mt_rand(-$stagger, $stagger)) , 0 , 0 , imagesx($next) , imagesy($next) ); } else { #($direction == "left") imagecopy( $temp , $wall , imagesx($next)-$distance, ($height-imagesy($wall))/2 , 0 , 0 , imagesx($wall) , imagesy($wall) ); imagecopy( $temp , $next , 0 , (intval(($height-imagesy($next))/2) + mt_rand(-$stagger, $stagger)) , 0 , 0 , imagesx($next) , imagesy($next) ); } $wall = imagecreatetruecolor($width, $height); # re-creating it so it will have the new size imagecolortransparent($wall, imagecolorallocate( $wall , 0 , 0 , 0 )); imagecopy( $wall , $temp , 0 , 0 , 0 , 0 , imagesx($temp) , imagesy($temp) ); } imagedestroy($next); imagedestroy($temp); # change colors, if the user wants to if (isset($_POST['setcolors']) && $_POST['setcolors'] == true) { imagetruecolortopalette($wall, true, 255); $primary_red = (isset($_POST['pred'])) ? $_POST['pred'] : 0; $primary_green = (isset($_POST['pgreen'])) ? $_POST['pgreen'] : 0; $primary_blue = (isset($_POST['pblue'])) ? $_POST['pblue'] : 0; $secondary_red = (isset($_POST['sred'])) ? $_POST['sred'] : 0; $secondary_green = (isset($_POST['sgreen'])) ? $_POST['sgreen'] : 0; $secondary_blue = (isset($_POST['sblue'])) ? $_POST['sblue'] : 0; imagecolorset($wall, 0, $primary_red, $primary_green, $primary_blue); imagecolorset($wall, 1, $secondary_red, $secondary_green, $secondary_blue); } # output if (isset($_POST['format']) && $_POST['format'] == "gif") { header('Content-type: image/gif'); imagegif($wall); } else { header('Content-type: image/png'); imagepng($wall, NULL, 9); } imagedestroy($wall); ?>