diff --git a/lib/graphlib.php b/lib/graphlib.php index 11aad5f2070..633e8540e79 100644 --- a/lib/graphlib.php +++ b/lib/graphlib.php @@ -1565,16 +1565,32 @@ class graph { ImageArc($this->image, $u, $v, $size, $size, 0, 360, $this->colour[$colour]); break; case 'diamond': - ImageFilledPolygon($this->image, array($u, $v-$half, $u+$half, $v, $u, $v+$half, $u-$half, $v), 4, $this->colour[$colour]); + if (version_compare(PHP_VERSION, '8.0.0', '>=')) { + ImageFilledPolygon($this->image, array($u, $v - $half, $u + $half, $v, $u, $v + $half, $u - $half, $v), $this->colour[$colour]); + } else { + ImageFilledPolygon($this->image, array($u, $v - $half, $u + $half, $v, $u, $v + $half, $u - $half, $v), 4, $this->colour[$colour]); + } break; case 'diamond-open': - ImagePolygon($this->image, array($u, $v-$half, $u+$half, $v, $u, $v+$half, $u-$half, $v), 4, $this->colour[$colour]); + if (version_compare(PHP_VERSION, '8.0.0', '>=')) { + ImagePolygon($this->image, array($u, $v - $half, $u + $half, $v, $u, $v + $half, $u - $half, $v), $this->colour[$colour]); + } else { + ImagePolygon($this->image, array($u, $v - $half, $u + $half, $v, $u, $v + $half, $u - $half, $v), 4, $this->colour[$colour]); + } break; case 'triangle': - ImageFilledPolygon($this->image, array($u, $v-$half, $u+$half, $v+$half, $u-$half, $v+$half), 3, $this->colour[$colour]); + if (version_compare(PHP_VERSION, '8.0.0', '>=')) { + ImageFilledPolygon($this->image, array($u, $v - $half, $u + $half, $v + $half, $u - $half, $v + $half), $this->colour[$colour]); + } else { + ImageFilledPolygon($this->image, array($u, $v - $half, $u + $half, $v + $half, $u - $half, $v + $half), 3, $this->colour[$colour]); + } break; case 'triangle-open': - ImagePolygon($this->image, array($u, $v-$half, $u+$half, $v+$half, $u-$half, $v+$half), 3, $this->colour[$colour]); + if (version_compare(PHP_VERSION, '8.0.0', '>=')) { + ImagePolygon($this->image, array($u, $v - $half, $u + $half, $v + $half, $u - $half, $v + $half), $this->colour[$colour]); + } else { + ImagePolygon($this->image, array($u, $v - $half, $u + $half, $v + $half, $u - $half, $v + $half), 3, $this->colour[$colour]); + } break; case 'dot': ImageSetPixel($this->image, $u, $v, $this->colour[$colour]); @@ -1665,11 +1681,15 @@ class graph { switch ($type) { case 'fill': // draw it this way 'cos the FilledPolygon routine seems a bit buggy. - ImageFilledPolygon($this->image, array($u_start, $v_start, $u_end, $v_end, $u_end, $zero, $u_start, $zero), 4, $this->colour[$colour]); - ImagePolygon($this->image, array($u_start, $v_start, $u_end, $v_end, $u_end, $zero, $u_start, $zero), 4, $this->colour[$colour]); - break; + if (version_compare(PHP_VERSION, '8.0.0', '>=')) { + ImageFilledPolygon($this->image, array($u_start, $v_start, $u_end, $v_end, $u_end, $zero, $u_start, $zero), $this->colour[$colour]); + ImagePolygon($this->image, array($u_start, $v_start, $u_end, $v_end, $u_end, $zero, $u_start, $zero), $this->colour[$colour]); + } else { + ImageFilledPolygon($this->image, array($u_start, $v_start, $u_end, $v_end, $u_end, $zero, $u_start, $zero), 4, $this->colour[$colour]); + ImagePolygon($this->image, array($u_start, $v_start, $u_end, $v_end, $u_end, $zero, $u_start, $zero), 4, $this->colour[$colour]); + } + break; case 'open': - //ImagePolygon($this->image, array($u_start, $v_start, $u_end, $v_end, $u_end, $zero, $u_start, $zero), 4, $this->colour[$colour]); ImageLine($this->image, $u_start, $v_start, $u_end, $v_end, $this->colour[$colour]); ImageLine($this->image, $u_start, $v_start, $u_start, $zero, $this->colour[$colour]); ImageLine($this->image, $u_end, $v_end, $u_end, $zero, $this->colour[$colour]); @@ -1686,11 +1706,19 @@ class graph { if ($this->parameter['inner_border'] != 'none') $bottom -= 1; // 1 pixel above bottom if border is to be drawn. switch ($type) { case 'fill': - ImageFilledPolygon($this->image, array($u_start, $v_start, $u_end, $v_end, $u_end, $bottom, $u_start, $bottom), 4, $this->colour[$colour]); - break; - case 'open': - ImagePolygon($this->image, array($u_start, $v_start, $u_end, $v_end, $u_end, $bottom, $u_start, $bottom), 4, $this->colour[$colour]); + if (version_compare(PHP_VERSION, '8.0.0', '>=')) { + ImageFilledPolygon($this->image, array($u_start, $v_start, $u_end, $v_end, $u_end, $bottom, $u_start, $bottom), $this->colour[$colour]); + } else { + ImageFilledPolygon($this->image, array($u_start, $v_start, $u_end, $v_end, $u_end, $bottom, $u_start, $bottom), 4, $this->colour[$colour]); + } break; + case 'open': + if (version_compare(PHP_VERSION, '8.0.0', '>=')) { + ImagePolygon($this->image, array($u_start, $v_start, $u_end, $v_end, $u_end, $bottom, $u_start, $bottom), $this->colour[$colour]); + } else { + ImagePolygon($this->image, array($u_start, $v_start, $u_end, $v_end, $u_end, $bottom, $u_start, $bottom), 4, $this->colour[$colour]); + } + break; } } } @@ -1776,18 +1804,38 @@ class graph { ImageFilledRectangle($this->image, $x-$half, $y, $x+$half, $y+1, $this->colour[$colour]); break; case 'slash': - ImageFilledPolygon($this->image, array($x+$half, $y-$half, - $x+$half+1, $y-$half, - $x-$half+1, $y+$half, - $x-$half, $y+$half - ), 4, $this->colour[$colour]); + if (version_compare(PHP_VERSION, '8.0.0', '>=')) { + ImageFilledPolygon($this->image, array( + $x + $half, $y - $half, + $x + $half + 1, $y - $half, + $x - $half + 1, $y + $half, + $x - $half, $y + $half + ), $this->colour[$colour]); + } else { + ImageFilledPolygon($this->image, array( + $x + $half, $y - $half, + $x + $half + 1, $y - $half, + $x - $half + 1, $y + $half, + $x - $half, $y + $half + ), 4, $this->colour[$colour]); + } break; case 'backslash': - ImageFilledPolygon($this->image, array($x-$half, $y-$half, - $x-$half+1, $y-$half, - $x+$half+1, $y+$half, - $x+$half, $y+$half - ), 4, $this->colour[$colour]); + if (version_compare(PHP_VERSION, '8.0.0', '>=')) { + ImageFilledPolygon($this->image, array( + $x - $half, $y - $half, + $x - $half + 1, $y - $half, + $x + $half + 1, $y + $half, + $x + $half, $y + $half + ), $this->colour[$colour]); + } else { + ImageFilledPolygon($this->image, array( + $x - $half, $y-$half, + $x - $half + 1, $y - $half, + $x + $half + 1, $y + $half, + $x + $half, $y + $half + ), 4, $this->colour[$colour]); + } break; default: @eval($type); // user can create own brush script.