Spiral Text (56k warning)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Spiral Text (56k warning)

Post 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);
   
?>
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Awesome. I love these creative little snips :D
Ree
Forum Regular
Posts: 592
Joined: Fri Jun 10, 2005 1:43 am
Location: LT

Post by Ree »

Nice stuff :)
Post Reply