1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
img.php
См. документацию.
1<?php
8
9/*******************************************************
10Converts ISO to UNICODE
11********************************************************/
12
13function iso2uni ($isoline)
14{
15 $uniline = "";
16 for ($i = 0, $n = mb_strlen($isoline); $i < $n; $i++)
17 {
18 $thischar = mb_substr($isoline, $i, 1);
19 $charcode = ord($thischar);
20 $uniline .= ($charcode>175) ? "&#" . (1040+($charcode-176)). ";" : $thischar;
21 }
22 return $uniline;
23}
24
25/*******************************************************
26Creates image to draw on
27********************************************************/
28
29function CreateImageHandle($width, $height, $background="FFFFFF", $truecolor=true)
30{
31 if($truecolor)
32 {
33 $im = ImageCreateTrueColor($width,$height);
34 }
35 else
36 {
37 $im = ImageCreate($width,$height);
38 }
39 if (!$im)
40 {
41 die ("Cannot Initialize GD image stream");
42 }
43 else
44 {
45 $dec = ReColor($background);
46 ImageColorAllocate ($im, $dec[0], $dec[1], $dec[2]);
47 }
48 return $im;
49}
50
51/******************************************************
52Send proper headers for image
53*******************************************************/
54function ShowImageHeader($ImageHandle)
55{
56 if (ImageTypes() & IMG_PNG)
57 {
58 Header("Content-type: image/png");
59 ImagePng($ImageHandle);
60 }
61 elseif(ImageTypes() & IMG_GIF)
62 {
63 Header("Content-type: image/gif");
64 ImageGif($ImageHandle);
65 }
66 elseif (ImageTypes() & IMG_JPEG)
67 {
68 Header("Content-type: image/jpeg");
69 ImageJpeg($ImageHandle, "", 0.5);
70 }
71 else
72 {
73 die("No images support");
74 }
75 ImageDestroy ($ImageHandle);
76}
77
78/******************************************************
79Returns some color
80*******************************************************/
81
83{
84 $arrSaveDecColor = array();
85 foreach($arr as $key => $scolor)
86 {
87 $arrSaveDecColor[$key] = hexdec($scolor);
88 }
89 asort($arrSaveDecColor);
90 return $arrSaveDecColor;
91}
92
93function GetNextRGB($base_color, $total)
94{
95 $arrSaveColor = getSafeColors();
96
97 $tsc = count($arrSaveColor);
98 if ($total > $tsc)
99 {
100 return GetBNextRGB($base_color, $total);
101 }
102 elseif ($base_color == '')
103 {
104 $res = "1288A0";
105 }
106 else
107 {
108 $index = 0;
109 $step = round($tsc/$total);
110 $dec = hexdec($base_color);
111 $arrSaveDecColor = GetArrSaveDecColor($arrSaveColor);
112 foreach($arrSaveDecColor as $key => $sdcolor)
113 {
114 if ($dec <= $sdcolor)
115 {
116 $index = $key;
117 break;
118 }
119 }
120 $index = intval($index);
121 $tsc = $tsc-1;
122 if ($index + $step > $tsc)
123 {
124 $rkey = ($index + $step) - $tsc;
125 }
126 else
127 {
128 $rkey = $index + $step;
129 }
130 $res = $arrSaveColor[$rkey];
131 }
132 return $res;
133}
134
135function GetBNextRGB($base_color, $total, $start_color = "999900", $end_color = "99FFFF")
136{
137 $step = round((hexdec($end_color) - hexdec($start_color)) / $total);
138 $dec = intval(hexdec($base_color)) + intval($step);
139
140 if ($dec < hexdec($start_color) - $step)
141 {
142 $dec = $start_color;
143 }
144 elseif ($dec > hexdec($end_color) + $step)
145 {
146 $dec = $end_color;
147 }
148 elseif ($dec > hexdec("FFFFFF"))
149 {
150 $dec = "000000";
151 }
152 else
153 {
154 $dec = sprintf("%06X", $dec);
155 }
156
157 return $dec;
158}
159
160/*******************************************************
161Graph data debug
162*******************************************************/
163
164function EchoGraphData($arrayX, $MinX, $MaxX, $arrayY, $MinY, $MaxY, $arrX, $arrY, $die=true)
165{
166 echo "<pre>";
167 echo "--------------------------------------\n";
168 foreach($arrX as $key => $value)
169 {
170 echo date("d.m.Y",$value)." = ".$arrY[$key]."\n";
171 }
172 echo "--------------------------------------\n";
173 echo "Signs of X axis (arrayX):\n";
174 print_r($arrayX);
175 echo "MinX: ".$MinX." - ".date("d.m",$MinX)."\n";
176 echo "MaxX: ".$MaxX." - ".date("d.m",$MaxX)."\n\n";
177 echo "Signs of Y axis (arrayY):\n";
178 print_r($arrayY);
179 echo "MinY: ".$MinY."\n";
180 echo "MaxY: ".$MaxY."\n\n";
181 echo "Values of X axis (arrX):\n";
182 $i = 0;
183 foreach ($arrX as $d)
184 {
185 echo "[".$i."] => ".GetTime($d)." (".$d.")"."\n";
186 $i++;
187 }
188 echo "\nValues of Y axis (arrY):\n";
189 print_r($arrY);
190 echo "--------------------------------------\n";
191 echo "</pre>";
192 if ($die)
193 {
194 die();
195 }
196}
197
198/*******************************************************
199Makes proper X axis (date)
200*******************************************************/
201function GetArrayX($arrX, &$MinX, &$MaxX, $max_grid=15, $min_grid=10)
202{
203 $h = 2;
204
205 $MinX = (!empty($arrX)) ? min($arrX) : 0;
206 $MaxX = (!empty($arrX)) ? max($arrX) : 0;
207 $period_days = (($MaxX-$MinX)/86400)+1;
208 if ($period_days>$min_grid)
209 {
210 $h = $min_grid;
211 }
212 if ($max_grid<$h)
213 {
214 $max_grid = $h;
215 }
216 $arrOst = array();
217 for ($i=$max_grid; $i>=$h; $i--)
218 {
219 $ost = $period_days%$i;
220 $arrOst[$i] = $ost;
221 if ($ost == 0)
222 {
223 break;
224 }
225 }
226 $minOst = min($arrOst);
227 $shiftX = ($period_days/array_search($minOst, $arrOst));
228 $shiftX = $shiftX*86400;
229 $unix_date = $MinX;
230 if(preg_match("/(DD|MM)(.*?)(DD|MM)/",FORMAT_DATE,$arMatch))
231 {
232 $strFrmt = str_replace(array("DD","MM"), array("d","m"), $arMatch[0]);
233 }
234 else
235 {
236 $strFrmt = "d.m";
237 }
238 $prev_date = "";
239 $tmp_arrX = array();
240 $arrayX = array();
241 while ($unix_date < $MaxX+$shiftX)
242 {
243 if ($prev_date == date("d.m.Y", $unix_date))
244 {
245 $unix_date += 3600;
246 }
247 $date = date($strFrmt, $unix_date);
248 $arrayX[] = $date;
249 $tmp_arrX[] = $unix_date;
250 $unix_date += $shiftX;
251 $prev_date = date("d.m.Y", $unix_date);
252 }
253
254 $MinX = MkDateTime(date("d.m.Y", min($tmp_arrX)),"d.m.Y");
255 $MaxX = MkDateTime(date("d.m.Y", max($tmp_arrX)),"d.m.Y");
256
257 return $arrayX;
258}
259
260
261function GetArrayY($arrY, &$MinY, &$MaxY, $max_grid=15, $first_null="Y", $integers=false)
262{
263 $arrayY = array();
264 $arrY = array_unique($arrY);
265 if ($first_null=="Y")
266 {
267 $arrY[] = 0;
268 }
269 asort($arrY);
270 $MinY = min($arrY);
271 $MaxY = max($arrY);
272 if ($MinY==$MaxY)
273 {
274 if ($MinY!=0)
275 {
276 $arrayY[] = 0;
277 }
278 $arrayY[] = $MinY;
279 $arrayY[] = $MaxY+1;
280 asort($arrayY);
281 }
282 else
283 {
284 $shiftY = round(($MaxY-$MinY)/$max_grid);
285 if($shiftY<=0)
286 {
287 if($integers==false)
288 {
289 $shiftY = round(($MaxY-$MinY)/$max_grid,3);
290 }
291 else
292 {
293 $shiftY = 1;
294 }
295 }
296 if ($shiftY>0)
297 {
298 $i = $MinY;
299 while ($i<$MaxY+$shiftY+$shiftY)
300 {
301 $arrayY[] = $i;
302 $i += $shiftY;
303 }
304 }
305 else
306 {
307 for ($i=$MinY; $i<=$MaxY+$shiftY+$shiftY; $i++)
308 {
309 $arrayY[] = $i;
310 }
311 }
312 }
313 $MinY = min($arrayY);
314 $MaxY = max($arrayY);
315 return $arrayY;
316}
317
318/******************************************************************************
319* $colorString - Color. Example 'FFFFFF' or '#FF0000'
320* ReColor - function converting HEX to DEC color
321******************************************************************************/
322function ReColor($colorString)
323{
324 if (!is_string($colorString))
325 return 0;
326
327 if (!preg_match('/^#{0,1}([0-9a-z]{2})([0-9a-z]{2})([0-9a-z]{2})$/i', $colorString, $match))
328 return 0;
329
330 return array(
331 hexdec($match[1]),
332 hexdec($match[2]),
333 hexdec($match[3]),
334 );
335}
336
337function DrawCoordinatGrid($arrayX, $arrayY, $width, $height, $ImageHandle, $bgColor="FFFFFF", $gColor='B1B1B1', $Color="000000", $dD=15, $FontWidth=2, $arrTTF_FONT=false)
338{
339 global $xA, $yA, $xPixelLength, $yPixelLength;
340
341 /******************************************************************************
342 * $k - array performance font size to pixel format
343 * array index == font size
344 ******************************************************************************/
345 $k = array();
346 $k[1]=5;
347 $k[2]=2.7;
348 $k[3]=2.3;
349 $k[4]=2;
350 $k[5]=1.7;
351 $k[6]=1.5;
352 $k[7]=1.3;
353 $k[8]=1.1;
354 $k[9]=1;
355 $k[10]=0.85;
356 $k[11]=0.75;
357 $k[12]=0.7;
358 $k[13]=0.65;
359 $k[14]=0.60;
360 $k[15]=0.55;
361 $k[16]=0.52;
362
363 $arResult = array();
364
365 $max_len=0;
366
367 $bUseTTFY = false;
368 $bUseTTFX = false;
369
370 if(is_array($arrTTF_FONT) && function_exists("ImageTTFText"))
371 {
372 $bUseTTFY = is_array($arrTTF_FONT["Y"] ?? null);
373 $bUseTTFX = is_array($arrTTF_FONT["X"] ?? null);
374 }
375
376 $ttf_font_y = "";
377 $ttf_size_y = $ttf_shift_y = $ttf_base_y = 0;
378
379 if ($bUseTTFY)
380 {
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"]))
385 {
386 $ttf_base_y = $arrTTF_FONT["Y"]["FONT_BASE"];
387 }
388 $dlataX = 0;
389 foreach($arrayY as $value)
390 {
391 $bbox = imagettfbbox($ttf_size_y, 0, $ttf_font_y, $value);
392 $dlataX = max($dlataX, abs($bbox[2] - $bbox[0]) + 1);
393 }
394 }
395 else
396 {
397 foreach($arrayY as $value)
398 $max_len=max($max_len, mb_strlen($value));
399 $dlataX = $max_len*ImageFontWidth($FontWidth);
400 }
401
402 $arr_bgColor = ReColor($bgColor);
403 $colorFFFFFF = ImageColorAllocate($ImageHandle,$arr_bgColor[0],$arr_bgColor[1],$arr_bgColor[2]);
404
405 $arr_Color = ReColor($Color);
406 $color000000 = ImageColorAllocate($ImageHandle,$arr_Color[0],$arr_Color[1],$arr_Color[2]);
407
408 $arr_gColor = ReColor($gColor);
409 $colorCOCOCO = ImageColorAllocate($ImageHandle,$arr_gColor[0], $arr_gColor[1], $arr_gColor[2]);
410
411 ImageFill($ImageHandle, 0, 0, $colorFFFFFF);
412
413 $bForBarDiagram = is_array($arrTTF_FONT) && (($arrTTF_FONT["type"] ?? '') == "bar");
414 if($bForBarDiagram)
415 {
416 $arResult["XBUCKETS"] = array();
417 }
418
419/*
420 C
421 |
422 |
423 |
424 |
425 |__________________
426 A B
427*/
428
429 $ttf_font_x = "";
430 $ttf_size_x = $ttf_shift_x = $ttf_base_x = 0;
431
432 $xA = $dD+$dlataX;
433 if ($bUseTTFX)
434 {
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"]))
439 {
440 $ttf_base_x = $arrTTF_FONT["X"]["FONT_BASE"];
441 }
442 $yA = $height-$dD-$ttf_shift_x;
443 }
444 else
445 {
446 $yA = $height-$dD-ImageFontHeight($FontWidth)/2;
447 }
448
449 $xC = $xA;
450 $yC = $dD;
451
452 $xB = $width-$dD;
453 $yB = $yA;
454
455 $GrafWidth = $xB - $xA;
456 $GrafHeight = $yA - $yC;
457
458 $PointsX = max(sizeof($arrayX)+$bForBarDiagram, 2);
459 $PointsY = max(sizeof($arrayY), 2);
460
461 $dX = $GrafWidth/($PointsX-1);
462 $dY = $GrafHeight/($PointsY-1);
463
464/*
465 C P1
466 | |
467 | |
468 | |
469 | |
470 |___|______________
471 A P0 B
472*/
473
474 $i=0;
475 $xP0 = $xA;
476 $yP0 = $yA;
477 $yP1 = $yC;
478 while ($i < $PointsX)
479 {
480 if ($i==$PointsX-1)
481 {
482 $xP0 = $xB;
483 }
484 $style = array (
485 $colorCOCOCO,
486 IMG_COLOR_TRANSPARENT,
487 IMG_COLOR_TRANSPARENT,
488 );
489 ImageSetStyle($ImageHandle, $style);
490 ImageLine($ImageHandle, ceil($xP0), ceil($yP0), ceil($xP0), ceil($yP1), IMG_COLOR_STYLED);
491
492 if($bForBarDiagram)
493 $arResult["XBUCKETS"][$i] = array(ceil($xP0)+1, ceil($xP0+$dX)-1);
494
495 $captionX = $arrayX[$i];
496 $xCaption = $xP0 - mb_strlen($captionX) * $k[$FontWidth] + ($dX*$bForBarDiagram/2);
497 $yCaption = $yP0;
498
499 if ($bUseTTFX)
500 {
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);
506 }
507 else ImageString($ImageHandle, $FontWidth, $xCaption, $yCaption+ImageFontHeight($FontWidth)/2, $captionX, $color000000);
508
509 $xP0 += $dX;
510 $i++;
511 }
512
513/*
514 C
515 |
516 |
517 |
518 M1|___________________ M0
519 |___________________
520 A B
521*/
522
523 $i=0;
524 $xM0 = $xB;
525 $yM0 = $yB;
526 $xM1 = $xA;
527 $yM1 = $yA;
528 while ($i < $PointsY)
529 {
530 if ($i==$PointsY-1)
531 {
532 $yM0 = $yC;
533 $yM1 = $yC;
534 }
535 if ($yM1>0 && $yM0>0)
536 {
537 $style = array (
538 $colorCOCOCO,
539 IMG_COLOR_TRANSPARENT,
540 IMG_COLOR_TRANSPARENT,
541 );
542 ImageSetStyle($ImageHandle, $style);
543 ImageLine($ImageHandle, ceil($xM0), ceil($yM0), ceil($xM1), ceil($yM1), IMG_COLOR_STYLED);
544 $captionY = $arrayY[$i];
545 $xCaption = $dlataX;
546 $yCaption = $yM1-$k[$FontWidth]*3;
547
548 if ($bUseTTFY)
549 {
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);
553 }
554 else ImageString($ImageHandle, $FontWidth, $xCaption- mb_strlen($captionY) * ImageFontWidth($FontWidth), $yCaption, $captionY, $color000000);
555 }
556 $yM0 -= $dY;
557 $yM1 -= $dY;
558 $i++;
559 }
560
561 ImageLine($ImageHandle, ceil($xA), ceil($yA), ceil($xC), ceil($yC), $color000000);
562 ImageLine($ImageHandle, ceil($xB), ceil($yB), ceil($xA), ceil($yA), $color000000);
563
564 $xPixelLength = $xB - $xA;
565 $yPixelLength = $yA - $yC;
566
567 $arResult["VIEWPORT"] = array(ceil($xA), ceil($yA), ceil($xB), ceil($yC));
568
569 return $arResult;
570}
571
572function Bar_Diagram($ImageHandle, $arData, $MinY, $MaxY, $gridInfo)
573{
574 $max_y = 0;
575 foreach($arData as $arRecs)
576 {
577 $y = max($arRecs["DATA"]);
578 if($y > $max_y)
579 $max_y = $y;
580 }
581 $scale = ($gridInfo["VIEWPORT"][1] - $gridInfo["VIEWPORT"][3]) / ($MaxY - $MinY);
582
583 $xIndex = 0;
584 foreach($arData as $arRecs)
585 {
586 $arPair = $gridInfo["XBUCKETS"][$xIndex];
587 if (is_array($arPair))
588 {
589 $bar_count = count($arRecs["DATA"]);
590 $bar_width = ceil(($arPair[1] - $arPair[0] - 1) * 0.7 / $bar_count);
591 $ws_width = round((($arPair[1] - $arPair[0] - 1) - ($bar_width * $bar_count)) / ($bar_count + 1));
592
593 foreach($arRecs["DATA"] as $i => $Y)
594 {
595 $arColor = ReColor($arRecs["COLORS"][$i][0]);
596 $color = ImageColorAllocate($ImageHandle, $arColor[0], $arColor[1], $arColor[2]);
597
598 $x1 = $arPair[0] + $ws_width + ($bar_width + $ws_width)*$i;
599 $y1 = round($Y*$scale);
600
601 if($y1 > 0)
602 {
603 imagefilledrectangle($ImageHandle,
604 $x1,
605 $gridInfo["VIEWPORT"][1]-$y1,
606 $x1 + $bar_width,
607 $gridInfo["VIEWPORT"][1]-1,
608 $color);
609 }
610 }
611 }
612 $xIndex++;
613 }
614}
615
616function Graf($arrayX, $arrayY, $ImageHandle, $MinX, $MaxX, $MinY, $MaxY, $Color='FF0000', $dashed="N", $thikness=2, $antialiase=true)
617{
618 global $xA, $yA, $xPixelLength, $yPixelLength;
619
620 if(sizeof($arrayX) != sizeof($arrayY))
621 {
622 return;
623 }
624
625 $arr_Color = ReColor($Color);
626 $color = ImageColorAllocate($ImageHandle, $arr_Color[0], $arr_Color[1], $arr_Color[2]);
627
628 $xGrafLength = $MaxX - $MinX;
629 $yGrafLength = $MaxY - $MinY;
630
631 if($antialiase)
632 {
633 $bgcolor = imagecolorallocate($ImageHandle, 255, 255, 255);
634 $fgcolors = imagecolorsforindex($ImageHandle, $color);
635 $bgcolors = imagecolorsforindex($ImageHandle, $bgcolor);
636 for( $i = 0; $i < 100; $i++ )
637 {
638 imagecolorallocate(
639 $ImageHandle,
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))
643 );
644 }
645 }
646
647 $x1 = $y1 = $x2 = $y2 = 0;
648
649 for($i = 0, $n = sizeof($arrayX)-1; $i < $n; $i++)
650 {
651 if ($xGrafLength>0)
652 {
653 $x1 = $xA + ((($arrayX[$i]-$MinX) * $xPixelLength) / $xGrafLength);
654 $x2 = $xA + ((($arrayX[$i+1]-$MinX) * $xPixelLength) / $xGrafLength);
655 }
656
657 if ($yGrafLength>0)
658 {
659 $y1 = $yA - ((($arrayY[$i]-$MinY) * $yPixelLength) / $yGrafLength);
660 $y2 = $yA - ((($arrayY[$i+1]-$MinY) * $yPixelLength) / $yGrafLength);
661 }
662
663 $x1 = ceil($x1);
664 $y1 = ceil($y1);
665 $x2 = ceil($x2);
666 $y2 = ceil($y2);
667
668 if($antialiase)
669 {
671 _a_draw_line($ImageHandle, $x1, $y1, $x2, $y2, $fgcolors, $dashed, 10, 4);
672 if($thikness>1)
673 {
674 if($y1<$y2)
675 {
676 _a_draw_line($ImageHandle, $x1-0.4, $y1+0.4, $x2-0.4, $y2+0.4, $fgcolors, $dashed, 10, 4);
677 _a_draw_line($ImageHandle, $x1+0.4, $y1-0.4, $x2+0.4, $y2-0.4, $fgcolors, $dashed, 10, 4);
678 }
679 else
680 {
681 _a_draw_line($ImageHandle, $x1+0.4, $y1+0.4, $x2+0.4, $y2+0.4, $fgcolors, $dashed, 10, 4);
682 _a_draw_line($ImageHandle, $x1-0.4, $y1-0.4, $x2-0.4, $y2-0.4, $fgcolors, $dashed, 10, 4);
683 }
684 }
685 }
686 elseif($dashed=="Y")
687 {
688 $style = array (
689 $color,$color,
690 IMG_COLOR_TRANSPARENT,
691 IMG_COLOR_TRANSPARENT,
692 IMG_COLOR_TRANSPARENT
693 );
694 ImageSetStyle($ImageHandle, $style);
695 ImageLine($ImageHandle, $x1, $y1, $x2, $y2, IMG_COLOR_STYLED);
696 }
697 else
698 {
699 ImageLine($ImageHandle, $x1, $y1, $x2, $y2, $color);
700 }
701 }
702}
703
704function Draw_Sector($ImageHandle, $start, $end, $color, $diameter, $centerX, $centerY)
705{
706 $radius = $diameter/2;
707 $dec = ReColor($color);
708 $color = ImageColorAllocate ($ImageHandle, $dec[0], $dec[1], $dec[2]);
709
710 imagearc($ImageHandle, $centerX, $centerY, $diameter, $diameter, 0, 360, $color);
711
712 $startX = $centerX + cos(deg2rad($start)) * $radius;
713 $startY = $centerY + sin(deg2rad($start)) * $radius;
714 imageline($ImageHandle, $centerX, $centerY, $startX, $startY, $color);
715
716 $endX = $centerX + cos(deg2rad($end)) * $radius;
717 $endY = $centerY + sin(deg2rad($end)) * $radius;
718 imageline($ImageHandle, $centerX, $centerY, $endX, $endY, $color);
719
720 $diff = intval($end - $start);
721 if ($diff < 180)
722 {
723 $x = ($centerX+(($startX + $endX)/2))/2;
724 $y = ($centerY+(($startY + $endY)/2))/2;
725 }
726 else
727 {
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;
733 //ImageString($ImageHandle, 2, 30, 30, $m_end, $color);
734 //imagesetpixel($ImageHandle, $m_X, $m_Y, ImageColorAllocate($ImageHandle,"FF", "00", "00"));
735 }
736 imagefill ($ImageHandle, $x, $y, $color);
737 //imagesetpixel($ImageHandle, $x, $y, $color);
738}
739
740function Circular_Diagram($ImageHandle, $arr, $background_color, $diameter, $centerX, $centerY, $antialiase=true)
741{
742 if($antialiase)
743 {
744 $ImageHandle_Saved = $ImageHandle;
745 $diameter_saved = $diameter;
746 $diameter=$diameter*5;
747 $centerX=$centerX*5;
748 $centerY=$centerY*5;
749 $ImageHandle = CreateImageHandle($diameter, $diameter, "FFFFFF", true);
750 imagefill($ImageHandle, 0, 0, imagecolorallocate($ImageHandle, 255,255,255));
751 }
752 $arr2 = array();
753 $diameterX = $diameter;
754 $diameterY = intval($diameter*0.6);
755 if(!empty($arr))
756 {
757 $sum = 0;
758 foreach($arr as $sector)
759 {
760 $sum += $sector["COUNTER"];
761 }
762 $degree1=0;
763 $p=0.0;
764 $i=0;
765 foreach($arr as $sector)
766 {
767 $p += $sector["COUNTER"]/$sum*360.0;
768 ++$i;
769 if ($i==count($arr))
770 {
771 $degree2 = 360;
772 }
773 else
774 {
775 $degree2 = intval($p);
776 }
777 if($degree2 > $degree1)
778 {
779 $dec = ReColor($sector["COLOR"]);
780 $arr2[] = array(
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),
786 );
787 $degree1 = $degree2;
788 }
789 }
790 if(!empty($arr2))
791 {
792 $h = 15;
793 if($antialiase)
794 {
795 $h = $h * 5;
796 }
797 for($i = 0; $i <= $h; $i++)
798 {
799 foreach($arr2 as $sector)
800 {
801 $degree1 = $sector["DEGREE_1"];
802 $degree2 = $sector["DEGREE_2"];
803 $difference = $degree2 - $degree1;
804 $degree1 -= 180;
805 $degree1 = $degree1<0?360+$degree1:$degree1;
806 $degree2 -= 180;
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);
811 else
812 imagearc($ImageHandle, $centerX, $centerY-$i, $diameterX, $diameterY, $degree1, $degree2, $color);
813 }
814 }
815 $i--;
816 foreach($arr2 as $sector)
817 {
818 $degree1 = $sector["DEGREE_1"];
819 $degree2 = $sector["DEGREE_2"];
820 $difference = $degree2 - $degree1;
821 $degree1 -= 180;
822 $degree1 = $degree1<0?360+$degree1:$degree1;
823 $degree2 -= 180;
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);
828 else
829 {
830 imagefilledarc($ImageHandle, $centerX, $centerY-$i, $diameterX, $diameterY, $degree1, $degree2, $color, IMG_ARC_PIE);
831 }
832 }
833 }
834 }
835 else
836 {
837 $dec = ReColor($background_color);
838 $color= ImageColorAllocate ($ImageHandle, $dec[0], $dec[1], $dec[2]);
839 imagefilledellipse($ImageHandle, $centerX, $centerY, $diameterX, $diameterY, $color);
840 }
841 if($antialiase)
842 {
844 imagecopyresampled($ImageHandle_Saved, $ImageHandle, 0, 0, 0, 0, $diameter_saved, $diameter_saved, $diameter, $diameter);
845 }
846}
847
848function Clean_Circular_Diagram($ImageHandle, $background_color, $diameter, $centerX, $centerY)
849{
850 $dec = ReColor($background_color);
851 $color = ImageColorAllocate ($ImageHandle, $dec[0], $dec[1], $dec[2]);
852 for($i=0;$i<=$diameter;$i++) imagearc($ImageHandle, $centerX, $centerY, $diameter+$i, $diameter+$i, 0, 360, $color);
853}
854
855function _a_set_pixel($im, $x, $y, $filled, $fgcolors)
856{
857 $rgb=imagecolorat($im, $x, $y);
858 $r = ($rgb >> 16) & 0xFF;
859 $g = ($rgb >> 8) & 0xFF;
860 $b = $rgb & 0xFF;
861
862 $red = round($r + ( $fgcolors['red'] - $r ) * $filled);
863 $green = round($g + ( $fgcolors['green'] - $g ) * $filled);
864 $blue = round($b + ( $fgcolors['blue'] - $b ) * $filled);
865 imagesetpixel($im, $x, $y, imagecolorclosest($im, $red, $green, $blue));
866}
867
868function _a_frac($x)
869{
870 $x = doubleval($x);
871 return $x-floor($x);
872}
873
874function _a_draw_line($im, $x1, $y1, $x2, $y2, $fgcolors, $dashed="N", $dash=5, $white=2)
875{
876 $xd = $x2-$x1;
877 $yd = $y2-$y1;
878 if($xd==0 && $yd==0)
879 {
880 return;
881 }
882 if(abs($xd)>abs($yd))
883 {
884 $wasexchange = false;
885 }
886 else
887 {
888 $wasexchange = true;
889 $tmpreal = $x1;
890 $x1 = $y1;
891 $y1 = $tmpreal;
892 $tmpreal = $x2;
893 $x2 = $y2;
894 $y2 = $tmpreal;
895 $tmpreal = $xd;
896 $xd = $yd;
897 $yd = $tmpreal;
898 }
899 if( $x1>$x2 )
900 {
901 $tmpreal = $x1;
902 $x1 = $x2;
903 $x2 = $tmpreal;
904 $tmpreal = $y1;
905 $y1 = $y2;
906 $y2 = $tmpreal;
907 $xd = $x2-$x1;
908 $yd = $y2-$y1;
909 }
910 $grad = $yd/$xd;
911 $xend = floor($x1+0.5);
912 $yend = $y1+$grad*($xend-$x1);
913 $xgap = 1-_a_frac($x1+0.5);
914 $ix1 = floor($x1+0.5);
915 $iy1 = floor($yend);
916 $brightness1 = (1-_a_frac($yend))*$xgap;
917 $brightness2 = _a_frac($yend)*$xgap;
918 if( $wasexchange )
919 {
920 _a_set_pixel($im, $iy1, $ix1, $brightness1, $fgcolors);
921 _a_set_pixel($im, $iy1+1, $ix1, $brightness2, $fgcolors);
922 }
923 else
924 {
925 _a_set_pixel($im, $ix1, $iy1, $brightness1, $fgcolors);
926 _a_set_pixel($im, $ix1, $iy1+1, $brightness2, $fgcolors);
927 }
928 $yf = $yend+$grad;
929 $xend = floor($x2+0.5);
930 $yend = $y2+$grad*($xend-$x2);
931 $xgap = 1-_a_frac($x2-0.5);
932 $ix2 = floor($x2+0.5);
933 $iy2 = floor($yend);
934 $brightness1 = (1-_a_frac($yend))*$xgap;
935 $brightness2 = _a_frac($yend)*$xgap;
936 if( $wasexchange )
937 {
938 _a_set_pixel($im, $iy2, $ix2, $brightness1, $fgcolors);
939 _a_set_pixel($im, $iy2+1, $ix2, $brightness2, $fgcolors);
940 }
941 else
942 {
943 _a_set_pixel($im, $ix2, $iy2, $brightness1, $fgcolors);
944 _a_set_pixel($im, $ix2, $iy2+1, $brightness2, $fgcolors);
945 }
946 $kk=0;
947 for($x = $ix1+1; $x <= $ix2-1; $x++)
948 {
949 if(($kk % $dash)<($dash-$white))
950 {
951 $brightness1 = 1-_a_frac($yf);
952 $brightness2 = _a_frac($yf);
953 if( $wasexchange )
954 {
955 _a_set_pixel($im, floor($yf), $x, $brightness1, $fgcolors);
956 _a_set_pixel($im, floor($yf)+1, $x, $brightness2, $fgcolors);
957 }
958 else
959 {
960 _a_set_pixel($im, $x, floor($yf), $brightness1, $fgcolors);
961 _a_set_pixel($im, $x, floor($yf)+1, $brightness2, $fgcolors);
962 }
963 }
964 $yf = $yf+$grad;
965 if($dashed=="Y")
966 ++$kk;
967 }
968}
969function _a_draw_ellipse($im, $x1, $y1, $x2, $y2, $fgcolors, $half=false)
970{
971 if( $x2<$x1 )
972 {
973 $t = $x1;
974 $x1 = $x2;
975 $x2 = $t;
976 }
977 if( $y2<$y1 )
978 {
979 $t = $y1;
980 $y1 = $y2;
981 $y2 = $t;
982 }
983 if( $x2-$x1<$y2-$y1 )
984 {
985 $exch = false;
986 }
987 else
988 {
989 $exch = true;
990 $t = $x1;
991 $x1 = $y1;
992 $y1 = $t;
993 $t = $x2;
994 $x2 = $y2;
995 $y2 = $t;
996 }
997 $a = ($x2-$x1)/2;
998 $b = ($y2-$y1)/2;
999 $cx = ($x1+$x2)/2;
1000 $cy = ($y1+$y2)/2;
1001 $t = $a*$a/sqrt($a*$a+$b*$b);
1002 $i1 = floor($cx-$t);
1003 $i2 = ceil($cx+$t);
1004 for($ix = $i1; $ix <= $i2; $ix++)
1005 {
1006 if( 1-pow(($ix-$cx)/$a, 2)<0 )
1007 {
1008 continue;
1009 }
1010 $y = $b*sqrt(1-pow(($ix-$cx)/$a, 2));
1011 $iy = ceil($cy+$y);
1012 $f = $iy-$cy-$y;
1013 if( !$exch )
1014 {
1015 if(!$half || $iy>$cx) _a_set_pixel($im, $ix, $iy, 1-$f, $fgcolors);
1016 if(!$half || $iy>$cx) _a_set_pixel($im, $ix, $iy-1, $f, $fgcolors);
1017 }
1018 else
1019 {
1020 if(!$half || $ix>$cx) _a_set_pixel($im, $iy, $ix, 1-$f, $fgcolors);
1021 if(!$half || $ix>$cx) _a_set_pixel($im, $iy-1, $ix, $f, $fgcolors);
1022 }
1023 $iy = floor($cy-$y);
1024 $f = $cy-$y-$iy;
1025 if( !$exch )
1026 {
1027 if(!$half || $iy>$cx) _a_set_pixel($im, $ix, $iy+1, $f, $fgcolors);
1028 if(!$half || $iy>$cx) _a_set_pixel($im, $ix, $iy, 1-$f, $fgcolors);
1029 }
1030 else
1031 {
1032 if(!$half || $ix>$cx) _a_set_pixel($im, $iy+1, $ix, $f, $fgcolors);
1033 if(!$half || $ix>$cx) _a_set_pixel($im, $iy, $ix, 1-$f, $fgcolors);
1034 }
1035 }
1036 $t = $b*$b/sqrt($a*$a+$b*$b);
1037 $i1 = ceil($cy-$t);
1038 $i2 = floor($cy+$t);
1039 for($iy = $i1; $iy <= $i2; $iy++)
1040 {
1041 if( 1-pow(($iy-$cy)/$b, 2)<0 )
1042 {
1043 continue;
1044 }
1045 $x = $a*sqrt(1-pow(($iy-$cy)/$b, 2));
1046 $ix = floor($cx-$x);
1047 $f = $cx-$x-$ix;
1048 if( !$exch )
1049 {
1050 if(!$half || $iy>$cx) _a_set_pixel($im, $ix, $iy, 1-$f, $fgcolors);
1051 if(!$half || $iy>$cx) _a_set_pixel($im, $ix+1, $iy, $f, $fgcolors);
1052 }
1053 else
1054 {
1055 if(!$half || $ix>$cx) _a_set_pixel($im, $iy, $ix, 1-$f, $fgcolors);
1056 if(!$half || $ix>$cx) _a_set_pixel($im, $iy, $ix+1, $f, $fgcolors);
1057 }
1058 $ix = ceil($cx+$x);
1059 $f = $ix-$cx-$x;
1060 if( !$exch )
1061 {
1062 if(!$half || $iy>$cx) _a_set_pixel($im, $ix, $iy, 1-$f, $fgcolors);
1063 if(!$half || $iy>$cx) _a_set_pixel($im, $ix-1, $iy, $f, $fgcolors);
1064 }
1065 else
1066 {
1067 if(!$half || $ix>$cx) _a_set_pixel($im, $iy, $ix, 1-$f, $fgcolors);
1068 if(!$half || $ix>$cx) _a_set_pixel($im, $iy, $ix-1, $f, $fgcolors);
1069 }
1070 }
1071}
1072
1074{
1075 static $colors = array(
1076 "CCCCCC",
1077 "999999",
1078 "FF0000",
1079 "FF3333",
1080 "CC0000",
1081 "FF6666",
1082 "CC3333",
1083 "990000",
1084 "FF9999",
1085 "CC6666",
1086 "993333",
1087 "FFCCCC",
1088 "CC9999",
1089 "996666",
1090 "FF3300",
1091 "FF6633",
1092 "CC3300",
1093 "FF9966",
1094 "CC6633",
1095 "993300",
1096 "FF6600",
1097 "FF9933",
1098 "CC6600",
1099 "FFCC99",
1100 "CC9966",
1101 "996633",
1102 "FF9900",
1103 "FFCC66",
1104 "CC9933",
1105 "996600",
1106 "CC9900",
1107 "FFCC33",
1108 "FFCC00",
1109 "FFFF00",
1110 "FFFF33",
1111 "CCCC00",
1112 "FFFF66",
1113 "CCCC33",
1114 "999900",
1115 "FFFF99",
1116 "CCCC66",
1117 "999933",
1118 "FFFFCC",
1119 "CCCC99",
1120 "999966",
1121 "A2CA00",
1122 "CCFF33",
1123 "99CC00",
1124 "CCFF66",
1125 "99CC33",
1126 "669900",
1127 "99FF00",
1128 "99FF33",
1129 "66CC00",
1130 "73E600",
1131 "99CC66",
1132 "669933",
1133 "66FF00",
1134 "99FF66",
1135 "66CC33",
1136 "339900",
1137 "66FF33",
1138 "33CC00",
1139 "33FF00",
1140 "00FF00",
1141 "33FF33",
1142 "00CC00",
1143 "66FF66",
1144 "33CC33",
1145 "009900",
1146 "99FF99",
1147 "66CC66",
1148 "339933",
1149 "00AA00",
1150 "99CC99",
1151 "669966",
1152 "00FF33",
1153 "33FF66",
1154 "00CC33",
1155 "66FF99",
1156 "33CC66",
1157 "009933",
1158 "00FF66",
1159 "33FF99",
1160 "00CC66",
1161 "99FFCC",
1162 "66CC99",
1163 "339966",
1164 "00FF99",
1165 "66FFCC",
1166 "33CC99",
1167 "009966",
1168 "33FFCC",
1169 "00CC99",
1170 "00FFCC",
1171 "00FFFF",
1172 "33FFFF",
1173 "00CCCC",
1174 "66FFFF",
1175 "33CCCC",
1176 "009999",
1177 "99FFFF",
1178 "66CCCC",
1179 "339999",
1180 "CCFFFF",
1181 "99CCCC",
1182 "669999",
1183 "00CCFF",
1184 "33CCFF",
1185 "0099CC",
1186 "66CCFF",
1187 "3399CC",
1188 "006699",
1189 "0099FF",
1190 "3399FF",
1191 "0066CC",
1192 "99CCFF",
1193 "6699CC",
1194 "336699",
1195 "599BFF",
1196 "6699FF",
1197 "3366CC",
1198 "003399",
1199 "3366FF",
1200 "0033CC",
1201 "0033FF",
1202 "0000FF",
1203 "3333FF",
1204 "0000CC",
1205 "6666FF",
1206 "3333CC",
1207 "000099",
1208 "9999FF",
1209 "6666CC",
1210 "333399",
1211 "CCCCFF",
1212 "9999CC",
1213 "666699",
1214 "0A7BB8",
1215 "6633FF",
1216 "3300CC",
1217 "9966FF",
1218 "5997D5",
1219 "330099",
1220 "6600FF",
1221 "9933FF",
1222 "1AA9F7",
1223 "CC99FF",
1224 "9966CC",
1225 "663399",
1226 "9900FF",
1227 "CC66FF",
1228 "CE37CE",
1229 "660099",
1230 "CC33FF",
1231 "9900CC",
1232 "CC00FF",
1233 "FF00FF",
1234 "FF33FF",
1235 "CC00CC",
1236 "FF66FF",
1237 "CC33CC",
1238 "990099",
1239 "FF99FF",
1240 "CC66CC",
1241 "993399",
1242 "FFCCFF",
1243 "CC99CC",
1244 "996699",
1245 "FF00CC",
1246 "FF33CC",
1247 "CC0099",
1248 "FF66CC",
1249 "CC3399",
1250 "990066",
1251 "FF0099",
1252 "FF3399",
1253 "CC0066",
1254 "FF99CC",
1255 "CC6699",
1256 "993366",
1257 "FF0066",
1258 "FF6699",
1259 "CC3366",
1260 "990033",
1261 "FF3366",
1262 "CC0033",
1263 "FF0033",
1264 );
1265
1266 return $colors;
1267}
$sum
Определения checkout.php:6
$arResult
Определения generate_coupon.php:16
$f
Определения component_props.php:52
$arr
Определения file_new.php:624
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
$start
Определения get_search.php:9
$p
Определения group_list_element_edit.php:23
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
CreateImageHandle($width, $height, $background="FFFFFF", $truecolor=true)
Определения img.php:29
EchoGraphData($arrayX, $MinX, $MaxX, $arrayY, $MinY, $MaxY, $arrX, $arrY, $die=true)
Определения img.php:164
_a_frac($x)
Определения img.php:868
_a_draw_ellipse($im, $x1, $y1, $x2, $y2, $fgcolors, $half=false)
Определения img.php:969
GetArrSaveDecColor($arr)
Определения img.php:82
ReColor($colorString)
Определения img.php:322
Graf($arrayX, $arrayY, $ImageHandle, $MinX, $MaxX, $MinY, $MaxY, $Color='FF0000', $dashed="N", $thikness=2, $antialiase=true)
Определения img.php:616
iso2uni($isoline)
Определения img.php:13
GetArrayY($arrY, &$MinY, &$MaxY, $max_grid=15, $first_null="Y", $integers=false)
Определения img.php:261
GetBNextRGB($base_color, $total, $start_color="999900", $end_color="99FFFF")
Определения img.php:135
Draw_Sector($ImageHandle, $start, $end, $color, $diameter, $centerX, $centerY)
Определения img.php:704
_a_draw_line($im, $x1, $y1, $x2, $y2, $fgcolors, $dashed="N", $dash=5, $white=2)
Определения img.php:874
Bar_Diagram($ImageHandle, $arData, $MinY, $MaxY, $gridInfo)
Определения img.php:572
ShowImageHeader($ImageHandle)
Определения img.php:54
GetNextRGB($base_color, $total)
Определения img.php:93
getSafeColors()
Определения img.php:1073
GetArrayX($arrX, &$MinX, &$MaxX, $max_grid=15, $min_grid=10)
Определения img.php:201
DrawCoordinatGrid($arrayX, $arrayY, $width, $height, $ImageHandle, $bgColor="FFFFFF", $gColor='B1B1B1', $Color="000000", $dD=15, $FontWidth=2, $arrTTF_FONT=false)
Определения img.php:337
Circular_Diagram($ImageHandle, $arr, $background_color, $diameter, $centerX, $centerY, $antialiase=true)
Определения img.php:740
Clean_Circular_Diagram($ImageHandle, $background_color, $diameter, $centerX, $centerY)
Определения img.php:848
_a_set_pixel($im, $x, $y, $filled, $fgcolors)
Определения img.php:855
const FORMAT_DATE
Определения include.php:63
GetTime($timestamp, $type="SHORT", $site=false, $bSearchInSitesOnly=false)
Определения tools.php:1890
MkDateTime($strDT, $format="d.m.Y H:i:s")
Определения tools.php:1977
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
if(empty($signedUserToken)) $key
Определения quickway.php:257
die
Определения quickway.php:367
$i
Определения factura.php:643
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
$background
Определения html.php:27
$width
Определения html.php:68
else $a
Определения template.php:137
$y1
Определения pdf.php:133
$y2
Определения pdf.php:144
$x2
Определения pdf.php:124
$k
Определения template_pdf.php:567
$n
Определения update_log.php:107
$x1
Определения template_pdf.php:419