Page 1 of 1

Spiral Text (56k warning)

Posted: Sun Dec 04, 2005 1:52 pm
by onion2k
Another pointless code snippet ..

Image

Code: Select all

<?php

    $text = "Around and around around and around and around and around around and around and around and around around and around and around ";
   
    $image = imagecreatetruecolor(400,400);
    $white = imagecolorallocate($image,255,255,255);
    imagefill($image,0,0,$white);
    $red = imagecolorallocate($image,255,0,0);

    $degrees = (360/(strlen($text)/3));

    for ($i=0;$i<strlen($text);$i++) {

        $a = ($degrees*$i)+180;

        $cos = cos(deg2rad($a));
        $sin = sin(deg2rad($a));
        $x = 0;
        $y = 180-$i;
        $xt = round($cos*($x) - $sin*($y));
        $yt = round($sin*($x) + $cos*($y));
        imagettftext($image,20,180-($a),200+$xt,200+$yt,$red,"fonts/AIRSTREA.TTF",$text[$i]);
       
    }
   
    header("Content-type: image/jpeg");
    imagejpeg($image,"",100);
    imagedestroy($image);
   
?>

Posted: Sun Dec 04, 2005 2:33 pm
by Chris Corbyn
Awesome. I love these creative little snips :D

Posted: Sun Dec 04, 2005 2:44 pm
by Ree
Nice stuff :)