Why my little brother my php-generated pictures don't show

Source: Internet
Author: User
Why my PHP generated pictures do not show
//+------------------------+
//| Pie3dfun. php//Common Functions |
//+------------------------+
Define ("Angle_step", 3); Defines the angle step when drawing an elliptical arc
Define ("font_used", "C:\WINDOWS\Fonts\simhei.ttf"); The font file location to use
function Draw_getdarkcolor ($img, $CLR)//$CLR the corresponding dark color
{
$rgb = Imagecolorsforindex ($img, $CLR);
return Array ($rgb ["Red"]/2, $rgb ["Green"]/2, $rgb ["Blue"]/2);
}
function draw_getexy ($a, $b, $d)//$d point coordinates on the ellipse corresponding to the angle
{
$d = Deg2rad ($d);
Return Array (round ($a *cos ($d)), round ($b *sin ($d)));
}
function Draw_arc ($img, $ox, $oy, $a, $b, $SD, $ed, $CLR)//Elliptical arc function
{
$n = Ceil (($ed-$SD)/angle_step);
$d = $SD;
List ($x 0, $y 0) = draw_getexy ($a, $b, $d);
for ($i =0; $i < $n; $i + +)
{
$d = ($d +angle_step) > $ed $ed:($d +angle_step);
List ($x, $y) = Draw_getexy ($a, $b, $d);
Imageline ($img, $x 0+ $ox, $y 0+ $oy, $x + $ox, $y + $oy, $CLR);
$x 0 = $x;
$y 0 = $y;
}
}
function Draw_sector ($img, $ox, $oy, $a, $b, $SD, $ed, $CLR)//Draw slices
{
$n = Ceil (($ed-$SD)/angle_step);
$d = $SD;
List ($x 0, $y 0) = draw_getexy ($a, $b, $d);
Imageline ($img, $x 0+ $ox, $y 0+ $oy, $ox, $oy, $CLR);
for ($i =0; $i < $n; $i + +)
{
$d = ($d +angle_step) > $ed $ed:($d +angle_step);
List ($x, $y) = Draw_getexy ($a, $b, $d);
Imageline ($img, $x 0+ $ox, $y 0+ $oy, $x + $ox, $y + $oy, $CLR);
$x 0 = $x;
$y 0 = $y;
}
Imageline ($img, $x 0+ $ox, $y 0+ $oy, $ox, $oy, $CLR);
List ($x, $y) = Draw_getexy ($a/2, $b/2, ($d + $sd)/2);
Imagefill ($img, $x + $ox, $y + $oy, $CLR);
}
function Draw_sector3d ($img, $ox, $oy, $a, $b, $v, $SD, $ed, $clr)//3d fan
{
Draw_sector ($img, $ox, $oy, $a, $b, $SD, $ed, $CLR);
if ($SD <180)
{
List ($R, $G, $B) = Draw_getdarkcolor ($img, $CLR);
$CLR =imagecolorallocate ($img, $R, $G, $B);
if ($ed >180) $ed = 180;
List ($SX, $sy) = Draw_getexy ($a, $b, $SD);
$SX + = $ox;
$sy + = $oy;
List ($ex, $ey) = Draw_getexy ($a, $b, $ed);
$ex + = $ox;
$ey + = $oy;
Imageline ($img, $SX, $sy, $SX, $sy + $v, $CLR);
Imageline ($img, $ex, $ey, $ex, $ey + $v, $CLR);
Draw_arc ($img, $ox, $oy + $v, $a, $b, $SD, $ed, $CLR);
List ($SX, $sy) = Draw_getexy ($a, $b, ($SD + $ed)/2);
$sy + = $oy + $v/2;
$SX + = $ox;
Imagefill ($img, $SX, $sy, $CLR);
}
}
function Draw_getindexcolor ($img, $CLR)//RBG goto Index Color
{
$R = ($clr >>16) & 0xFF;
$G = ($clr >>8) & 0xFF;
$B = ($CLR) & 0xFF;
Return Imagecolorallocate ($img, $R, $G, $B);
}
Draw the main function and output the picture
$datLst as an array of data, $datLst as an array of labels, $datLst as an array of colors
The dimensions of the above three arrays should be equal
function draw_img ($datLst, $labLst, $clrLst, $a =200, $b =90, $v =20, $font =10)
{
$ox = 5+ $a;
$oy = 5+ $b;
$FW = Imagefontwidth ($font);
$fh = Imagefontheight ($font);
$n = count ($datLst);//number of data items
$w = $a
$h = $b *2+ $v + ($fh +2) * $n;
$img = Imagecreate ($w, $h);
Turn RGB to indexed color
for ($i =0; $i < $n; $i + +)
$clrLst [$i] = Draw_getindexcolor ($img, $clrLst [$i]);
$CLRBK = Imagecolorallocate ($img, 0xFF, 0xFF, 0xff);
$CLRT = Imagecolorallocate ($img, 0x00, 0x00, 0x00);
Fill background color
Imagefill ($img, 0, 0, $CLRBK);
Sum
$tot = 0;
for ($i =0; $i < $n; $i + +)
  • 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.