337function DrawCoordinatGrid($arrayX, $arrayY,
$width, $height, $ImageHandle, $bgColor=
"FFFFFF", $gColor=
'B1B1B1', $Color=
"000000", $dD=15, $FontWidth=2, $arrTTF_FONT=
false)
339 global $xA, $yA, $xPixelLength, $yPixelLength;
370 if(is_array($arrTTF_FONT) && function_exists(
"ImageTTFText"))
372 $bUseTTFY = is_array($arrTTF_FONT[
"Y"] ??
null);
373 $bUseTTFX = is_array($arrTTF_FONT[
"X"] ??
null);
377 $ttf_size_y = $ttf_shift_y = $ttf_base_y = 0;
381 $ttf_font_y =
$_SERVER[
"DOCUMENT_ROOT"].$arrTTF_FONT[
"Y"][
"FONT_PATH"];
382 $ttf_size_y = $arrTTF_FONT[
"Y"][
"FONT_SIZE"];
383 $ttf_shift_y = $arrTTF_FONT[
"Y"][
"FONT_SHIFT"];
384 if (isset($arrTTF_FONT[
"Y"][
"FONT_BASE"]))
386 $ttf_base_y = $arrTTF_FONT[
"Y"][
"FONT_BASE"];
389 foreach($arrayY as $value)
391 $bbox = imagettfbbox($ttf_size_y, 0, $ttf_font_y, $value);
392 $dlataX = max($dlataX, abs($bbox[2] - $bbox[0]) + 1);
397 foreach($arrayY as $value)
398 $max_len=max($max_len, mb_strlen($value));
399 $dlataX = $max_len*ImageFontWidth($FontWidth);
402 $arr_bgColor =
ReColor($bgColor);
403 $colorFFFFFF = ImageColorAllocate($ImageHandle,$arr_bgColor[0],$arr_bgColor[1],$arr_bgColor[2]);
406 $color000000 = ImageColorAllocate($ImageHandle,$arr_Color[0],$arr_Color[1],$arr_Color[2]);
408 $arr_gColor =
ReColor($gColor);
409 $colorCOCOCO = ImageColorAllocate($ImageHandle,$arr_gColor[0], $arr_gColor[1], $arr_gColor[2]);
411 ImageFill($ImageHandle, 0, 0, $colorFFFFFF);
413 $bForBarDiagram = is_array($arrTTF_FONT) && (($arrTTF_FONT[
"type"] ??
'') ==
"bar");
430 $ttf_size_x = $ttf_shift_x = $ttf_base_x = 0;
435 $ttf_font_x =
$_SERVER[
"DOCUMENT_ROOT"].$arrTTF_FONT[
"X"][
"FONT_PATH"];
436 $ttf_size_x = $arrTTF_FONT[
"X"][
"FONT_SIZE"];
437 $ttf_shift_x = $arrTTF_FONT[
"X"][
"FONT_SHIFT"];
438 if (isset($arrTTF_FONT[
"X"][
"FONT_BASE"]))
440 $ttf_base_x = $arrTTF_FONT[
"X"][
"FONT_BASE"];
442 $yA = $height-$dD-$ttf_shift_x;
446 $yA = $height-$dD-ImageFontHeight($FontWidth)/2;
455 $GrafWidth = $xB - $xA;
456 $GrafHeight = $yA - $yC;
458 $PointsX = max(
sizeof($arrayX)+$bForBarDiagram, 2);
459 $PointsY = max(
sizeof($arrayY), 2);
461 $dX = $GrafWidth/($PointsX-1);
462 $dY = $GrafHeight/($PointsY-1);
478 while (
$i < $PointsX)
486 IMG_COLOR_TRANSPARENT,
487 IMG_COLOR_TRANSPARENT,
489 ImageSetStyle($ImageHandle, $style);
490 ImageLine($ImageHandle, ceil($xP0), ceil($yP0), ceil($xP0), ceil($yP1), IMG_COLOR_STYLED);
495 $captionX = $arrayX[
$i];
496 $xCaption = $xP0 - mb_strlen($captionX) *
$k[$FontWidth] + ($dX*$bForBarDiagram/2);
501 $bbox = imagettfbbox($ttf_size_x, 0, $ttf_font_x, $captionX);
502 $ttf_width_x = abs($bbox[2] - $bbox[0]) + 1;
503 $xCaption = $xP0 - $ttf_width_x/2 + ($dX*$bForBarDiagram/2);
504 $yCaption = $yP0 + $dD + $ttf_shift_x - $ttf_base_x;
505 ImageTTFText($ImageHandle, $ttf_size_x, 0, $xCaption, $yCaption, $color000000, $ttf_font_x, $captionX);
507 else ImageString($ImageHandle, $FontWidth, $xCaption, $yCaption+ImageFontHeight($FontWidth)/2, $captionX, $color000000);
528 while (
$i < $PointsY)
535 if ($yM1>0 && $yM0>0)
539 IMG_COLOR_TRANSPARENT,
540 IMG_COLOR_TRANSPARENT,
542 ImageSetStyle($ImageHandle, $style);
543 ImageLine($ImageHandle, ceil($xM0), ceil($yM0), ceil($xM1), ceil($yM1), IMG_COLOR_STYLED);
544 $captionY = $arrayY[
$i];
546 $yCaption = $yM1-
$k[$FontWidth]*3;
550 $bbox = imagettfbbox($ttf_size_y, 0, $ttf_font_y, $captionY);
551 $yCaption = $yM1+($ttf_shift_y-$ttf_base_y)/2;
552 ImageTTFText($ImageHandle, $ttf_size_y, 0, $xCaption-abs($bbox[2]-$bbox[0])-1, $yCaption, $color000000, $ttf_font_y, $captionY);
554 else ImageString($ImageHandle, $FontWidth, $xCaption- mb_strlen($captionY) * ImageFontWidth($FontWidth), $yCaption, $captionY, $color000000);
561 ImageLine($ImageHandle, ceil($xA), ceil($yA), ceil($xC), ceil($yC), $color000000);
562 ImageLine($ImageHandle, ceil($xB), ceil($yB), ceil($xA), ceil($yA), $color000000);
564 $xPixelLength = $xB - $xA;
565 $yPixelLength = $yA - $yC;
567 $arResult[
"VIEWPORT"] =
array(ceil($xA), ceil($yA), ceil($xB), ceil($yC));
616function Graf($arrayX, $arrayY, $ImageHandle, $MinX, $MaxX, $MinY, $MaxY, $Color=
'FF0000', $dashed=
"N", $thikness=2, $antialiase=
true)
618 global $xA, $yA, $xPixelLength, $yPixelLength;
620 if(
sizeof($arrayX) !=
sizeof($arrayY))
626 $color = ImageColorAllocate($ImageHandle, $arr_Color[0], $arr_Color[1], $arr_Color[2]);
628 $xGrafLength = $MaxX - $MinX;
629 $yGrafLength = $MaxY - $MinY;
633 $bgcolor = imagecolorallocate($ImageHandle, 255, 255, 255);
634 $fgcolors = imagecolorsforindex($ImageHandle, $color);
635 $bgcolors = imagecolorsforindex($ImageHandle, $bgcolor);
636 for(
$i = 0;
$i < 100;
$i++ )
640 (
int)(($fgcolors[
'red'] +
$i*$bgcolors[
'red'])/(
$i + 1)),
641 (
int)(($fgcolors[
'green'] +
$i*$bgcolors[
'green'])/(
$i + 1)),
642 (
int)(($fgcolors[
'blue'] +
$i*$bgcolors[
'blue'])/(
$i + 1))
649 for(
$i = 0,
$n =
sizeof($arrayX)-1;
$i <
$n;
$i++)
653 $x1 = $xA + ((($arrayX[
$i]-$MinX) * $xPixelLength) / $xGrafLength);
654 $x2 = $xA + ((($arrayX[
$i+1]-$MinX) * $xPixelLength) / $xGrafLength);
659 $y1 = $yA - ((($arrayY[
$i]-$MinY) * $yPixelLength) / $yGrafLength);
660 $y2 = $yA - ((($arrayY[
$i+1]-$MinY) * $yPixelLength) / $yGrafLength);
690 IMG_COLOR_TRANSPARENT,
691 IMG_COLOR_TRANSPARENT,
692 IMG_COLOR_TRANSPARENT
694 ImageSetStyle($ImageHandle, $style);
695 ImageLine($ImageHandle,
$x1,
$y1,
$x2,
$y2, IMG_COLOR_STYLED);
706 $radius = $diameter/2;
708 $color = ImageColorAllocate ($ImageHandle, $dec[0], $dec[1], $dec[2]);
710 imagearc($ImageHandle, $centerX, $centerY, $diameter, $diameter, 0, 360, $color);
712 $startX = $centerX + cos(deg2rad(
$start)) * $radius;
713 $startY = $centerY + sin(deg2rad(
$start)) * $radius;
714 imageline($ImageHandle, $centerX, $centerY, $startX, $startY, $color);
716 $endX = $centerX + cos(deg2rad($end)) * $radius;
717 $endY = $centerY + sin(deg2rad($end)) * $radius;
718 imageline($ImageHandle, $centerX, $centerY, $endX, $endY, $color);
720 $diff = intval($end -
$start);
723 $x = ($centerX+(($startX + $endX)/2))/2;
724 $y = ($centerY+(($startY + $endY)/2))/2;
728 $m_end =
$start + $diff/2;
729 $m_X = $centerX + cos(deg2rad($m_end)) * $radius;
730 $m_Y = $centerY + sin(deg2rad($m_end)) * $radius;
731 $x = ($centerX+$m_X)/2;
732 $y = ($centerY+$m_Y)/2;
736 imagefill ($ImageHandle, $x, $y, $color);
740function Circular_Diagram($ImageHandle,
$arr, $background_color, $diameter, $centerX, $centerY, $antialiase=
true)
744 $ImageHandle_Saved = $ImageHandle;
745 $diameter_saved = $diameter;
746 $diameter=$diameter*5;
750 imagefill($ImageHandle, 0, 0, imagecolorallocate($ImageHandle, 255,255,255));
753 $diameterX = $diameter;
754 $diameterY = intval($diameter*0.6);
758 foreach(
$arr as $sector)
760 $sum += $sector[
"COUNTER"];
765 foreach(
$arr as $sector)
767 $p += $sector[
"COUNTER"]/
$sum*360.0;
775 $degree2 = intval(
$p);
777 if($degree2 > $degree1)
779 $dec =
ReColor($sector[
"COLOR"]);
781 "DEGREE_1" => $degree1,
782 "DEGREE_2" => $degree2,
783 "COLOR" => $sector[
"COLOR"],
784 "IMAGE_COLOR" => ImageColorAllocate ($ImageHandle, $dec[0], $dec[1], $dec[2]),
785 "IMAGE_DARK" => ImageColorAllocate ($ImageHandle, $dec[0]/1.5, $dec[1]/1.5, $dec[2]/1.5),
797 for(
$i = 0;
$i <= $h;
$i++)
799 foreach($arr2 as $sector)
801 $degree1 = $sector[
"DEGREE_1"];
802 $degree2 = $sector[
"DEGREE_2"];
803 $difference = $degree2 - $degree1;
805 $degree1 = $degree1<0?360+$degree1:$degree1;
807 $degree2 = $degree2<0?360+$degree2:$degree2;
808 $color =
$i==$h?$sector[
"IMAGE_COLOR"]:$sector[
"IMAGE_DARK"];
809 if ($difference==360)
810 imageellipse($ImageHandle, $centerX, $centerY-
$i, $diameterX, $diameterY, $color);
812 imagearc($ImageHandle, $centerX, $centerY-
$i, $diameterX, $diameterY, $degree1, $degree2, $color);
816 foreach($arr2 as $sector)
818 $degree1 = $sector[
"DEGREE_1"];
819 $degree2 = $sector[
"DEGREE_2"];
820 $difference = $degree2 - $degree1;
822 $degree1 = $degree1<0?360+$degree1:$degree1;
824 $degree2 = $degree2<0?360+$degree2:$degree2;
825 $color =
$i==$h?$sector[
"IMAGE_COLOR"]:$sector[
"IMAGE_DARK"];
826 if ($difference==360)
827 imagefilledellipse($ImageHandle, $centerX, $centerY-
$i, $diameterX, $diameterY, $color);
830 imagefilledarc($ImageHandle, $centerX, $centerY-
$i, $diameterX, $diameterY, $degree1, $degree2, $color, IMG_ARC_PIE);
837 $dec =
ReColor($background_color);
838 $color= ImageColorAllocate ($ImageHandle, $dec[0], $dec[1], $dec[2]);
839 imagefilledellipse($ImageHandle, $centerX, $centerY, $diameterX, $diameterY, $color);
844 imagecopyresampled($ImageHandle_Saved, $ImageHandle, 0, 0, 0, 0, $diameter_saved, $diameter_saved, $diameter, $diameter);
882 if(abs($xd)>abs($yd))
884 $wasexchange =
false;
911 $xend = floor(
$x1+0.5);
912 $yend =
$y1+$grad*($xend-
$x1);
914 $ix1 = floor(
$x1+0.5);
916 $brightness1 = (1-
_a_frac($yend))*$xgap;
917 $brightness2 =
_a_frac($yend)*$xgap;
921 _a_set_pixel($im, $iy1+1, $ix1, $brightness2, $fgcolors);
926 _a_set_pixel($im, $ix1, $iy1+1, $brightness2, $fgcolors);
929 $xend = floor(
$x2+0.5);
930 $yend =
$y2+$grad*($xend-
$x2);
932 $ix2 = floor(
$x2+0.5);
934 $brightness1 = (1-
_a_frac($yend))*$xgap;
935 $brightness2 =
_a_frac($yend)*$xgap;
939 _a_set_pixel($im, $iy2+1, $ix2, $brightness2, $fgcolors);
944 _a_set_pixel($im, $ix2, $iy2+1, $brightness2, $fgcolors);
947 for($x = $ix1+1; $x <= $ix2-1; $x++)
949 if(($kk % $dash)<($dash-$white))
955 _a_set_pixel($im, floor($yf), $x, $brightness1, $fgcolors);
956 _a_set_pixel($im, floor($yf)+1, $x, $brightness2, $fgcolors);
960 _a_set_pixel($im, $x, floor($yf), $brightness1, $fgcolors);
961 _a_set_pixel($im, $x, floor($yf)+1, $brightness2, $fgcolors);
CreateImageHandle($width, $height, $background="FFFFFF", $truecolor=true)
EchoGraphData($arrayX, $MinX, $MaxX, $arrayY, $MinY, $MaxY, $arrX, $arrY, $die=true)
_a_draw_ellipse($im, $x1, $y1, $x2, $y2, $fgcolors, $half=false)
Graf($arrayX, $arrayY, $ImageHandle, $MinX, $MaxX, $MinY, $MaxY, $Color='FF0000', $dashed="N", $thikness=2, $antialiase=true)
GetArrayY($arrY, &$MinY, &$MaxY, $max_grid=15, $first_null="Y", $integers=false)
GetBNextRGB($base_color, $total, $start_color="999900", $end_color="99FFFF")
Draw_Sector($ImageHandle, $start, $end, $color, $diameter, $centerX, $centerY)
_a_draw_line($im, $x1, $y1, $x2, $y2, $fgcolors, $dashed="N", $dash=5, $white=2)
Bar_Diagram($ImageHandle, $arData, $MinY, $MaxY, $gridInfo)
GetNextRGB($base_color, $total)
GetArrayX($arrX, &$MinX, &$MaxX, $max_grid=15, $min_grid=10)
DrawCoordinatGrid($arrayX, $arrayY, $width, $height, $ImageHandle, $bgColor="FFFFFF", $gColor='B1B1B1', $Color="000000", $dD=15, $FontWidth=2, $arrTTF_FONT=false)
Circular_Diagram($ImageHandle, $arr, $background_color, $diameter, $centerX, $centerY, $antialiase=true)
Clean_Circular_Diagram($ImageHandle, $background_color, $diameter, $centerX, $centerY)
_a_set_pixel($im, $x, $y, $filled, $fgcolors)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)