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.