Php drawing example, drawing example _ PHP Tutorial

Source: Internet
Author: User
Php drawing instance and drawing instance. Php drawing example. This article describes the php drawing method. Share it with you for your reference. The specific implementation method is as follows: Copy the code as follows: phpbyMoreWindo php drawing instance and drawing instance

This article describes the php plotting method. 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.


PHP does not support drawing.

Put the header at the beginning and try again. If not, return an error.
Header ("Content-Type: image/gif ");
$ Img = imagecreatetruecolor (50, 50 );

PHP drawing problems, urgent

1) Check whether your PHP does not support the GD Library. In windows,
Simply remove the semicolon before extension = php_gd2.dll in php. ini.
For linux systems, check the instructions on installing the GD library in the php Reference Manual.

2) sample code:

// Create an image of 520*300,
$ Im = imagecreatetruecolor (520,300 );
Imagefilledrectangle ($ im, 0, 0,520,300, 0 xFFFFFF );
Imageline ($ im, 10,270,510,270, 0x000000 );
......

// Save the image to file and free memory
Imagepng ($ im, 'photo_stamp.png ');
Imagedestroy ($ im );
?>
3) draw other systems in sequence.

Examples in this article describes the php plotting method. Share it with you for your reference. The code is as follows: php // by MoreWindo...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.