This article mainly introduces the method of drawing a five-star red flag Based on the GD library in php, which involves the usage skills of using the GD library and array in php, and has some reference value. For more information, see
This article mainly introduces the method of drawing a five-star red flag Based on the GD library in php, which involves the usage skills of using the GD library and array in php, and has some reference value. For more information, see
This example describes how to draw a five-star red flag in php Based on the GD library. 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.