PHP Object Programming Implementation 3D pie chart _php Tutorial

Source: Internet
Author: User
Common functions
Convert the angle to radians
function Deg2arc ($degrees) {
Return ($degrees * (pi ()/180.0));
}
Rgb
function getRGB ($color) {
$R = ($color >>16) & 0xFF;
$G = ($color >>8) & 0xFF;
$B = ($color) & 0xFF;
Return (Array ($R, $G, $B));
}
Gets the value of the X, Y point on an ellipse with an elliptical heart (0,0)
function Pie_point ($deg, $va, $VB) {
$x = cos (DEG2ARC ($deg)) * $VA;
$y = sin (Deg2arc ($deg)) * $VB;
Return (Array ($x, $y));
}
3D Pie Chart Class
Class pie3d{
var $a; Elliptical Long Half axis
var $b; Elliptic Short Half axis
var $DataArray; Each sector of the data
var $ColorArray; The color of each sector is required to be written in hexadecimal but not 0x in front
Black for edges and shadows
function Pie3d ($pa =100, $pb =60, $sData = "100,200,300,400,500", $sColor = "EE00FF,DD0000,CCCCCC,CCFF00,00CCFF")
{
$this->a= $pa;
$this->b= $PB;
$this->dataarray=split (",", $sData);
$this->colorarray=split (",", $sColor);
}
function SetA ($v) {
$this->a= $v;
}
function Geta () {
return $this->a;
}
function Setb ($v) {
$this->b= $v;
}
function Getb () {
return $this->b;
}
function Setdataarray ($v) {
$this->dataarray=split (",", $v);
}
function Getdataarray ($v) {
return $this->dataarray;
}
function Setcolorarray ($v) {
$this->colorarray=split (",", $v);
}
function Getcolorarray () {
return $this->colorarray;
}

function Drawpie () {
$image =imagecreate ($this->a*2+40, $this->b*2+40);
$PieCenterX = $this->a+10;
$PieCenterY = $this->b+10;
$DoubleA = $this->a*2;
$DoubleB = $this->b*2;
List ($R, $G, $B) =getrgb (0);
$colorBorder =imagecolorallocate ($image, $R, $G, $B);

http://www.bkjia.com/PHPjc/631788.html www.bkjia.com true http://www.bkjia.com/PHPjc/631788.html techarticle PHP//Common function//convert angle to radians function Deg2arc ($degrees) {return ($degrees * (pi ()/180.0))}//rgb function getRGB ($color) { $R = ($color) 0xFF; $G = ($color 8) 0xFF; ....

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