1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| <?php
header("Content-type: image/png");
$Chaines = array();
$AsciiArtChaine;
$DannelChaine = " __ __ __ __ _ __ ____ _ _ | \/ | \ \/ / _ _ | |/ / | _ \ | | | | | |\/| | \ / | | | | | ' / | | | | | |_| | | | | | / \ | |_| | | . \ | |_| | \__,_| |_| |_| /_/\_\ \__,_| |_|\_\ |____/";
$ImageSource = @imagecreate(260, 60) or die("Cannot Initialize new GD image stream");
$BackgroundColor = imagecolorallocate($ImageSource, 0, 0, 0);
$TextColor = imagecolorallocate($ImageSource, 255, 255, 255);
echo AsciiArt($DannelChaine);
#######################################################################
#Fonction qui construit un ascii char à partir d'une chaîne. #
#Elle retourne une variable et une image qui contiennent le Ascii Art.#
#######################################################################
function AsciiArt($EntryString) {
global $Chaines,$AsciiArtChaine,$ImageSource,$TextColor;
$LengthEntryString = strlen($EntryString);
$InsertionPosition = ceil($LengthEntryString / 5) ;
$Z= 0;
for ($Index = 0;$Index < 5 ; $Index++) {
$Chaines[] = substr($EntryString,0,$InsertionPosition);
imagestring($ImageSource, 1, 5, 5+$Z, substr($EntryString,0,$InsertionPosition), $TextColor);
$Z += 10;
$EntryString = substr($EntryString,$InsertionPosition,$LengthEntryString);
}
imagepng($ImageSource,"AsciiArt.png");
imagedestroy($ImageSource);
foreach($Chaines as $Chaine)
$AsciiArtChaine .= $Chaine."\r\n";
return $AsciiArtChaine;
}
?> |
Partager