Php's method of drawing a five-star red flag based on the GD Library

Source: Internet
Author: User
Tags image identifier
This article mainly introduces how to draw a five-star red flag based on the GD library of php, which involves the use of php operations on the GD library and array, and has some reference value, for more information about how to draw a five-star red flag based on the GD library, see the example in this article. Share it with you for your reference. The specific analysis is as follows:

Here we will analyze the five-star red flag (GD library) drawn by php. the code is as follows:

The code is as follows:

<? Php
Header ("Content-Type: image/jpeg ");
$ Ing = imagecreatetruecolor (700,410 );
// Create a true color image. the returned value is an image identifier. the default background is black. the parameter (x_size * y_size)
$ Red = imagecolorallocate ($ ing, 255, 0, 0); // defines the background color.
$ Yellow = imagecolorallocate ($ ing, 237,231, 32); // defines the yellow color.
Imagefill ($ ing, $ red); // fill color, starting with coordinates ()
// Array coordinate, indicating (x1, y1, x2, y2, x3, y3.... x11, y11 );
$ A = array (119,102,135,152, 93,123, 52,152, 66,102 );
Imagefilledpolygon ($ ing, $ a, 10, $ yellow); // draw a polygon: 10 indicates the total number of vertices, and $ yellow indicates the fill color.
$ A1 = array (, 25 );
Imagefilledpolygon ($ ing, $ a1, 10, $ yellow );
$ A2 = array (227,108,227,127,245,134,228,139,227,157,215,143,196,149,208,132,196,117,215,122,227,108 );
Imagefilledpolygon ($ ing, $ a2, 10, $ yellow );
$ A3 = array (163,184,163,204,181,211,163,216,163,234,152,220,132,225,144,209,132,193,151,199,163,184 );
Imagefilledpolygon ($ ing, $ a3, 10, $ yellow );
$ A4 = array (65,209, 65,228, 84,235, 65,240, 65,259, 54,245, 33,249, 46,233, 34,217, 53,224, 68,209 );
Imagefilledpolygon ($ ing, $ a4, 10, $ yellow );
Ob_clean ();
Imagejpeg ($ ing );
Imagedestroy ($ ing );
?>

I hope this article will help you with php programming.

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.