This article mainly introduces the php drawing method. the example describes how to draw images and text based on PHP. For more information, see the example below. Share it with you for your reference. The specific implementation method is as follows:
The code is as follows:
<? Php
// By MoreWindows
$ ImgWidth = 600;
$ ImgHeight = 400;
$ Img = imagecreatetruecolor ($ imgWidth, $ imgHeight );
Imagefill ($ img, 0, 0, imagecolorallocate ($ img, 240,240,240); // set the background color
$ Snowflake_size = 30;
$ Font_file = "c: \ WINDOWS \ Fonts \ simhei. ttf ";
// Generate a big snowflake, which is actually calling imagettftext () to output the * number
For ($ I = 1; $ I <= 400; $ I ++)
{
$ Font_color = imagecolorallocate ($ img, mt_rand (100,200), mt_rand (100,200), mt_rand (100,200 ));
Imagettftext ($ img, $ snowflake_size, mt_rand (0,180), mt_rand (0, $ imgWidth), mt_rand (0, $ imgHeight), $ font_color, $ font_file, "□ ");
}
// Watermark text
$ Black_color = imagecolorallocate ($ img, 0, 0 );
Imagettftext ($ img, 12, 0, $ imgWidth-50, $ imgHeight-20, $ black_color, $ font_file, "PHP drawing ");
Imagepng ($ img );
Imagedestroy ($ img );
?>
Shows the running effect of this instance.
For more information, see:
Http://www.php.net/manual/zh/refs.utilspec.image.php
I hope this article will help you with PHP programming.