PHP plot (3)

Source: Internet
Author: User
The last time we talked about using GD for various geometric figures and fill colors. This is a complicated situation.
Leave it behind, which is the fill color of any polygon and any polygon.
<?
Header ("Content-type: image/png ");
$ Im = ImageCreate (200,100 );
$ Col_blk = ImageColorAllocate ($ im, 0, 0 );
$ Col_grn = ImageColorAllocate ($ im, 0,255, 0 );
    
$ Parray = array );
// Define an array. The 12 members are the horizontal and vertical coordinates of the six points.
ImagePolygon ($ im, $ parray, 6, $ col_grn );
// This is the function for drawing arbitrary polygon. $ parray is the defined array,
// 6 indicates six points. Note that six points are connected to a hexagonal structure.
// You do not have to add the same vertex at the end to close the graph.
    
ImagePNG ($ im );
ImageDestroy ($ im );
?>
You should have thought of the function of filling any polygon color:
    
<?
Header ("Content-type: image/png ");
$ Im = ImageCreate (200,100 );
$ Col_blk = ImageColorAllocate ($ im, 0, 0 );
$ Col_orn = ImageColorAllocate ($ im, 255,192, 0 );
$ Col_yel = ImageColorAllocate ($ im, 255,255, 0 );
$ Col_red = ImageColorAllocate ($ im, 255, 0, 0 );
$ Col_grn = ImageColorAllocate ($ im, 0,255, 0 );
$ Col_blu = ImageColorAllocate ($ im, 255 );
$ Parray = array );
ImageFilledPolygon ($ im, $ parray, 6, $ col_grn );
    
ImagePNG ($ im );

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.