Why is my php image not displayed ;? Php & nbsp; + ---------------------- + & nbsp; | pie3dfun. PHP public functions | & nbsp; + ---------------------- + & nbsp; define (& quot; ANGLE_STEP & quot;, 3 ); define the corner when drawing an elliptical arc. Why is my php-generated image not displayed?
// + ------------------------ +
// | Pie3dfun. PHP // public function |
// + ------------------------ +
Define ("ANGLE_STEP", 3); // defines the angle step when an elliptical arc is drawn.
Define ("FONT_USED", "C: \ WINDOWS \ Fonts \ simhei. ttf"); // The position of the font file used
Function draw_getdarkcolor ($ img, $ clr) // Evaluate the dark color of $ clr
{
$ Rgb = imagecolorsforindex ($ img, $ clr );
Return array ($ rgb ["red"]/2, $ rgb ["green"]/2, $ rgb ["blue"]/2 );
}
Function draw_getexy ($ a, $ B, $ d) // calculates the coordinate of the point on the elliptic corresponding to the angle $ d.
{
$ D = deg 2rad ($ 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 ($ x0, $ y0) = 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, $ x0 + $ ox, $ y0 + $ oy, $ x + $ ox, $ y + $ oy, $ clr );
$ X0 = $ x;
$ Y0 = $ y;
}
}
Function draw_sector ($ img, $ ox, $ oy, $ a, $ B, $ sd, $ ed, $ clr) // draw a fan
{
$ N = ceil ($ ed-$ sd)/ANGLE_STEP );
$ D = $ sd;
List ($ x0, $ y0) = draw_getexy ($ a, $ B, $ d );
Imageline ($ img, $ x0 + $ ox, $ y0 + $ 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, $ x0 + $ ox, $ y0 + $ oy, $ x + $ ox, $ y + $ oy, $ clr );
$ X0 = $ x;
$ Y0 = $ y;
}
Imageline ($ img, $ x0 + $ ox, $ y0 + $ 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 surface
{
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) // Convert RBG to index color
{
$ R = ($ clr> 16) & 0xff;
$ G = ($ clr> 8) & 0xff;
$ B = ($ clr) & 0xff;
Return imagecolorallocate ($ img, $ R, $ G, $ B );
}
// Plot the main function and output the image
// $ DatLst is the data array, $ datLst is the tag array, and $ datLst is the color array.
// The dimensions of the preceding three arrays should be equal.
Function draw_img ($ datLst, $ labLst, $ clrLst, $ a = 200, $ B = 90, $ v = 20, $ font = 10)
{
$ Ox = 5 + $;
$ Oy = 5 + $ B;
$ Fw = imagefontwidth ($ font );
$ Fh = imagefontheight ($ font );
$ N = count ($ datLst); // number of data items
$ W = 10 + $ a * 2;
$ H = 10 + $ B * 2 + $ v + ($ fh + 2) * $ n;
$ Img = imagecreate ($ w, $ h );
// Convert RGB to index 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 in the background color
Imagefill ($ img, 0, 0, $ clrbk );
// Sum
$ Tot = 0;
For ($ I = 0; $ I <$ n; $ I ++)