This article describes the PHP based on the GD library painting flag method. Share to everyone for your reference. The specific analysis is as follows:
Here The example analyzes the PHP drawing flag (GD library), the code is as follows:
Copy Code code as follows:
<?php
Header ("Content-type:image/jpeg");
$ing = Imagecreatetruecolor (700,410);
Creates a new true color image with a return value of an image identifier, a background default of black, and a parameter (x_size*y_size)
$red = Imagecolorallocate ($ing, 255,0,0);//define Background color
$yellow = Imagecolorallocate ($ing, 237,231,32);//define Yellow
Imagefill ($ing, 0,0, $red);/fill color, starting with coordinates (0,0)
Array coordinates, representation (X1,Y1,X2,Y2,X3,Y3.....X11,Y11);
$a = array (90,30,108,73,157,73,119,102,135,152,93,123,52,152,66,102,29,74,76,73,90,30);
Imagefilledpolygon ($ing, $a, $yellow);//Draw a polygon: 10 represents the total number of vertices, $yellow represents the fill color
$a 1 = array (229,25,229,43,248,48,229,55,229,74,217,60,198,66,210,50,197,34,218,39,229,25);
Imagefilledpolygon ($ing, $a 1,10, $yellow);
$a 2 = 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, $a 2,10, $yellow);
$a 3 = 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, $a 3,10, $yellow);
$a 4 = 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, $a 4,10, $yellow);
Ob_clean ();
Imagejpeg ($ing);
Imagedestroy ($ing);
?>
I hope this article will help you with your PHP programming.