//draw a black rectangle
imagerectangle($image, 10, 10, 150, 150, $colorBlack);
//send image
header("Content-type: image/jpeg");
imagejpeg($image);
?>
boolean imagesetpixel(integer image, integer x, integer y,
integer color)
The imagesetpixel function sets a single pixel to the specified color.
<?
/*
* Draw 100 black dots
/
//create yellow square
$image = imagecreate(100, 100);
$colorYellow = imagecolorallocate($image, 255, 255, 0);
$colorBlack = imagecolorallocate($image, 0, 0, 0);
imagefill($image, 0, 0, $colorYellow);
//draw 100 random black dots
srand(time());
for($i=0; $i 100; $i++)
{
imagesetpixel($image, rand(0, 99), rand(0, 99), $colorBlack);
}
//send image
header("Content-type: image/jpeg");
imagejpeg($image);
?>
boolean imagestring(integer image, integer font, integer x,
integer y, string text, integer color)
The imagestring function draws the given text at the specified point. The top-left part of
the string will be at the specified point. The font argument may be a built-in font or one
loaded by imageloadfont.
Figure 12-8. imagestring.