PHP Dynamic Generation pie chart Code _php tutorial

Source: Internet
Author: User
Tags 0xc0
*/
Create an image
$image =imagecreatetruecolor (300,300);
Define the color required for the appeased chart
$white =imagecolorallocate ($image, 0xFF, 0xFF, 0xff);
$gray =imagecolorallocate ($image, 0xc0, 0xc0, 0xc0);
$darkgray =imagecolorallocate ($image, 0x90, 0x90, 0x90);
$navy =imagecolorallocate ($image, 0x00, 0x00, 0x80);
$darknavy =imagecolorallocate ($image, 0x00, 0x00, 0x50);
$red =imagecolorallocate ($image, 0xFF, 0x00, 0x00);
$darkred =imagecolorallocate ($image, 0x90, 0x00, 0x00);

/*
Imagecolorallocate--Assigning a color description to an image int imagecolorallocate (resource image, int red, int green, int blue) Imagecolor Allocate () returns an identifier that represents a color made up of a given RGB component. The image parameter is the return value of the Imagecreate () function. Red,green and Blue are the red, green, and blue components of the desired color respectively. These parameters are integers from 0 to 255 or hexadecimal 0x00 to 0xFF. Imagecolorallocate () must be called to create each color used in the image represented by image.
*/
Drawing
for ($i =160; $i >; $i-)
{
Imagefilledarc ($image, $i, 0, $darknavy, Img_arc_pie);
Imagefilledarc ($image, $i, $darkgray, and Img_arc_pie);
Imagefilledarc ($image, $i, $darkred, and Img_arc_pie);
}
Imagefilledarc ($image,-------0, $navy, Img_arc_pie);
Imagefilledarc ($image,,,,,,, Img_arc_pie, Max, Max, and $gray);
Imagefilledarc ($image,,,,,,,,,,, $red, Img_arc_pie);
Header (' content-type:image/png ');
Imagepng ($image);
Imagedestroy ($image);
/*
The Imagefilledarc () function allows you to fill an elliptical arc with a specified color while it is being drawn. With this function, you can easily draw a pie chart for statistics. The following shows how the Imagefilledarc () function is used

The code is executed as shown in result 22.8:
*/

Draw lines in pictures

Create a true Color image
$img =imagecreatetruecolor (300,300);
$white =imagecolorallocate ($img, 255,255,255);
$red =imagecolorallocate ($img, 255,0,0);
$green =imagecolorallocate ($img, 0,255,0);
Draw an ellipse on an image
Imagefilledellips Tutorial E ($img, 150,150,250,100, $red);
Imagefilledellipse ($img, 150,150,100,250, $green);
Output image
Header ("Content-type:image/png");
Imagepng ($IMG);
Destroying images
Imagedestroy ($IMG);
/*
The code is executed as shown in result 22.9:
*/

http://www.bkjia.com/PHPjc/632996.html www.bkjia.com true http://www.bkjia.com/PHPjc/632996.html techarticle *//Create Image $image =imagecreatetruecolor (300,300);//define appeased required color $white =imagecolorallocate ($image, 0xFF, 0xFF, 0xFF ); $gray =imagecolorallocate ($image,...

  • 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.