PHP generates 3D percent graphical statistical effects _php Tutorial

Source: Internet
Author: User
PHP generates a percentage of 3D graphics statistical effects This program is based on user-supplied data to produce a percentage of 3D effects picture statistic effect a bit like China webmaster

PHP tutorial generates 3d percent graphical stats effect
/*
This program is based on user-supplied data to generate a percentage of 3d effects picture statistics effect a bit like China webmaster
*/
$image = Imagecreatetruecolor (200,200); Create a 200*200 canvas;

Create multiple, differentiated colors
$red = Imagecolorallocate ($image, 255,0,0);
$blue = Imagecolorallocate ($image, 0,0,255);
$yellow = Imagecolorallocate ($image, 255,255,0);
$violet = Imagecolorallocate ($image, 255,0,255);
$white = Imagecolorallocate ($image, 255,255,255);
$black = Imagecolorallocate ($image, 0,0,0);


Create a 3d effect bottom effect with a for loop
for ($i =120; $i >100; $i-) {
Imagefilledarc ($image, $i, 200,120,0,30, $red, img_arc_pie);//img_arc_pie notes are as follows:

Imagefilledarc ($image, $i, 200,120,30,80, $blue, Img_arc_pie);
Imagefilledarc ($image, $i, 200,120,80,360, $yellow, Img_arc_pie);
}
BOOL Imagefilledarc (resource image, int cx, int cy, int w, int h, int s, int e, int color, int style)
//
Imagefilledarc () draws an elliptical arc in the image represented by the image as Cx,cy (0, 0) in the upper-left corner. Returns true if successful, and false if it fails. W and H Specify the width and height of the ellipse respectively, and the S and e parameters specify the starting and ending points with an angle. The style can be a bitwise or (or) value after the following values:
//
Img_arc_pie
//
Img_arc_chord
//
Img_arc_nofill
//
Img_arc_edged


This layer is the top layer of the effect, so the stereo effect is out!
Imagearc ($image, 100,100,200,120,0,360, $black);//Add a black rim so that the 3d effect looks more obvious.
Imagefilledarc ($image, 100,100,200,120,0,30, $red, Img_arc_pie);
Imagefilledarc ($image, 100,100,200,120,30,80, $blue, Img_arc_pie);
Imagefilledarc ($image, 100,100,200,120,80,360, $yellow, Img_arc_pie);

Add a percentage of data, of course, when necessary in this case can be batch of a certain operation will input input to the image
$str = Iconv ("GBK", "Utf-8", "36%");//If you want to enter Chinese, this conversion is required. Example: occupancy: 30%;
Imagettftext ($image, 10,360-15,100+70,115, $white, "Simhei.ttf", $str);

Imagejpeg ($image);
Imagedestroy ($image);

http://www.bkjia.com/PHPjc/633030.html www.bkjia.com true http://www.bkjia.com/PHPjc/633030.html techarticle PHP generates 3D percent graphical statistical effect this program is based on user-supplied data to generate a percentage of 3D effects picture statistical effects have a bit like the Chinese webmaster PHP tutorial generated 3d percent graphics ...

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