MDL-75945 core: Update uses of ImagePolygon

A new signature was introduced to ImagePolygon functions from PHP 8.0
with the previous signature deprecated in 8.1.

For PHP versions 8.0 and later we should use the new signature. Once PHP
8.0 is the required minimum version, the legacy version should be
removed.
This commit is contained in:
Andrew Nicols
2023-01-20 18:41:26 +07:00
committed by Meirza
parent df502b3e4c
commit 5b2e04f301
+70 -22
View File
@@ -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.