a random image maker based on the gd library (PNG)...
<?php
function setPenColors($theimage) {
        global $redpen, $greenpen, $bluepen, $blackpen, $whitepen, $yellowpen, 
$aquapen, $fuschiapen, $greypen, $silverpen, $tealpen, $limepen, $navypen, $purplepen, 
$maroonpen, $olivepen;
        $redpen = ImageColorAllocate($theimage, 255, 0, 0);
        $greenpen = ImageColorAllocate($theimage, 0, 153, 0);
        $bluepen = ImageColorAllocate($theimage, 0, 0, 255);
        $blackpen = ImageColorAllocate($theimage, 0, 0, 0);
        $whitepen = ImageColorAllocate($theimage, 255, 255, 255);
        $yellowpen = ImageColorAllocate($theimage, 255, 255, 0);
        $aquapen = ImageColorAllocate($theimage, 0, 255, 255);
        $fuschiapen = ImageColorAllocate($theimage, 255, 0, 255);
        $greypen = ImageColorAllocate($theimage, 153, 153, 153);
        $silverpen = ImageColorAllocate($theimage, 204, 204, 204);
        $tealpen = ImageColorAllocate($theimage, 0, 153, 153);
        $limepen = ImageColorAllocate($theimage, 0, 255, 0);
        $navypen = ImageColorAllocate($theimage, 0, 0, 153);
        $purplepen = ImageColorAllocate($theimage, 153, 0, 153);
        $maroonpen = ImageColorAllocate($theimage, 153, 0, 0);
        $olivepen = ImageColorAllocate($theimage, 153, 153, 0);
}
$servername = getenv("SERVER_NAME");

// set the content type
header("Content-type:  image/png");

$imageWidth = 118;
$imageHeight = 136;

// create image
$image = imageCreate($imageWidth, $imageHeight);

$bgcolor = ImageColorAllocate($image, 0, 0, 0);
$fgcolor = ImageColorAllocate($image, 255, 255, 255);
setPenColors($image);

srand ((double) microtime() * 1000000);
$rndnum = rand(10,60);
$oldx = rand(1,$imageWidth-2);
$oldy = rand(1,$imageHeight-18);
$pencolor = array 
($redpen,$greenpen,$bluepen,blackpen,$whitepen,$yellowpen,$aquapen,$fuschiapen,$greypen,$silverpen,$tealpen,$limepen,$navypen,$purplepen,$maroonpen,$olivepen);

$rndpen = rand(0,15);
ImageRectangle($image, 0, 0, $imageWidth-1, $imageHeight-17, $pencolor[$rndpen]);

for ($i=0; $i<$rndnum; $i++) {
        $rndpen = rand(0,15);
        $newx = rand(1,$imageWidth-2);
        $newy = rand(1,$imageHeight-18);
        ImageLine ($image, $oldx, $oldy, $newx, $newy, $pencolor[$rndpen]);
        $oldx = $newx;
        $oldy = $newy;
}

ImageString($image,2, 4, $imageHeight-14,  "Random Image Maker", $limepen);

// create an interlaced image for better loading in the browser
imageInterlace($image, 1);

// mark background color as being transparent
imageColorTransparent($image, $bgcolor);

// now send the picture to the client (this outputs all image data directly)
imagePNG($image);


?>
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to