1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | <?php require('libs/gif.class.php'); define('LARGEUR', 210); define('HAUTEUR', 25); $animation = array(); $duree = array(); $message = 'Mon premier gif en php'; $image = imagecreate(LARGEUR, HAUTEUR); $fond = imagecolorallocate($image, 255, 0, 0); $blanc = imagecolorallocate($image, 255, 255, 255); imagestring($image, 5, 5, 5, $message, $blanc); ob_start(); imagegif($image); $animation[] = ob_get_clean(); $duree[] = 100; imagedestroy($image); $gif = new GIFEncoder($animation, $duree, 0, 2, 0, 0, 0, "bin"); echo $gif->GetAnimation(); ?> |
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 | <?php require('libs/connexion.php'); //On se connecte à notre BDD require('libs/gif.class.php'); $retour = mysql_query('SELECT titre, timestamp FROM news_gif ORDER BY id DESC LIMIT 0, 1'); //Sélectionne le dernier article $donnees = mysql_fetch_array($retour); $chaine = $donnees['titre']; //La chaîne correspondra au dernier titre du blog $taille_chaine = strlen($chaine); str_split($chaine); //Transforme la chaîne en tableau $animation = array(); $duree = array(); $largeur = 220; $hauteur = 60; $image = imagecreatefromjpeg('fond_rss.jpg'); //Notre joli fond $fond = imagecolorallocate($image, 249, 249, 249); $bleu = imagecolorallocate($image, 0, 0, 255); $noir = imagecolorallocate($image, 9, 9, 9); $vert = imagecolorallocate($image, 146, 201, 146); imagestring($image, 5, 65, 5, "Bob's home", $bleu); //Un petit titre imagestring($image, 3, 9, 40, 'Le '.date('d/m/Y \a H\hi', $donnees['timestamp']), $vert); //Affiche la date de la dernière modification sur l'article foreach($chaine as $carac) //Pour chaque lettre de la chaîne, on crée une nouvelle image { $txt = $carac; //On affiche jusqu'au caractère actuel imagestring($image, 4, 9, 23, $txt, $noir); ob_start(); //Je ne vous explique pas : vous devriez avoir compris imagegif($image); $animation = ob_get_clean(); if($i+1 == $taille_chaine) //Si on est à la fin de la chaîne, on marque une pause $duree[] = 200; else $duree[] = 15; } imagedestroy($image); //On détruit l'image pour libérer de la mémoire $gif = new GIFEncoder($duree, $animation, 0, 2, 0, 0, 0, "bin"); //On génère l'animation $fichier = fopen('image.gif', 'w'); fputs($fichier, $gif->GetAnimation()); //On enregistre fclose($fichier); ?> |
Changer de design |
En savoir plus |
Plan du site |
Politique d'accessibilité |
Règles |
RSS tutoriels |
RSS news
Édité par Simple IT SARL :
Nous contacter
| Notre blog | Revue de presse | Publicité
Y'a plus rien à lire, faut remonter maintenant !
Hébergement web - Correction de tutoriels - Créer un site
Vous souhaitez apparaître ici ? Contactez-nous.
79 Zéros connectés |
5 requêtes |
0.0391s (0.0287s)