Skip to content

Commit

Permalink
Merge pull request #83 from szymach/php8.1
Browse files Browse the repository at this point in the history
Move casting values to integer to correct places
  • Loading branch information
szymach authored Aug 5, 2022
2 parents 9b903cb + 3412065 commit 373786c
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions src/Draw.php
Original file line number Diff line number Diff line change
Expand Up @@ -852,10 +852,6 @@ public function drawBezier($X1, $Y1, $X2, $Y2, $Xv1, $Yv1, $Xv2, $Yv2, array $Fo
*/
public function drawLine($X1, $Y1, $X2, $Y2, array $Format = [])
{
$X1 = (int) $X1;
$Y1 = (int) $Y1;
$X2 = (int) $X2;
$Y2 = (int) $Y2;
$R = isset($Format["R"]) ? $Format["R"] : 0;
$G = isset($Format["G"]) ? $Format["G"] : 0;
$B = isset($Format["B"]) ? $Format["B"] : 0;
Expand All @@ -877,16 +873,16 @@ public function drawLine($X1, $Y1, $X2, $Y2, array $Format = [])
);
imageline(
$this->Picture,
$X1 + $this->ShadowX,
$Y1 + $this->ShadowY,
$X2 + $this->ShadowX,
$Y2 + $this->ShadowY,
intval($X1 + $this->ShadowX),
intval($Y1 + $this->ShadowY),
intval($X2 + $this->ShadowX),
intval($Y2 + $this->ShadowY),
$ShadowColor
);
}

$Color = $this->allocateColor($this->Picture, $R, $G, $B, $Alpha);
imageline($this->Picture, $X1, $Y1, $X2, $Y2, $Color);
imageline($this->Picture, (int) $X1, (int) $Y1, (int) $X2, (int) $Y2, $Color);
return 0;
}

Expand Down Expand Up @@ -1188,8 +1184,6 @@ public function drawFilledCircle($X, $Y, $Radius, array $Format = [])
*/
public function drawText($X, $Y, $Text, array $Format = [])
{
$X = (int) $X;
$Y = (int) $Y;
$R = isset($Format["R"]) ? $Format["R"] : $this->FontColorR;
$G = isset($Format["G"]) ? $Format["G"] : $this->FontColorG;
$B = isset($Format["B"]) ? $Format["B"] : $this->FontColorB;
Expand Down Expand Up @@ -1449,8 +1443,6 @@ public function drawGradientArea($X1, $Y1, $X2, $Y2, $Direction, array $Format =
*/
public function drawAntialiasPixel($X, $Y, array $Format = [])
{
$X = (int) $X;
$Y = (int) $Y;
$R = isset($Format["R"]) ? $Format["R"] : 0;
$G = isset($Format["G"]) ? $Format["G"] : 0;
$B = isset($Format["B"]) ? $Format["B"] : 0;
Expand Down Expand Up @@ -1488,11 +1480,11 @@ public function drawAntialiasPixel($X, $Y, array $Format = [])
$this->ShadowB,
$this->Shadowa
);
imagesetpixel($this->Picture, $X + $this->ShadowX, $Y + $this->ShadowY, $ShadowColor);
imagesetpixel($this->Picture, intval($X + $this->ShadowX), intval($Y + $this->ShadowY), $ShadowColor);
}

$PlotColor = $this->allocateColor($this->Picture, $R, $G, $B, $Alpha);
imagesetpixel($this->Picture, $X, $Y, $PlotColor);
imagesetpixel($this->Picture, (int) $X, (int) $Y, $PlotColor);

return 0;
}
Expand Down Expand Up @@ -1541,9 +1533,6 @@ public function drawAntialiasPixel($X, $Y, array $Format = [])
*/
public function drawAlphaPixel($X, $Y, $Alpha, $R, $G, $B)
{
$X = (int) $X;
$Y = (int) $Y;

if (isset($this->Mask[$X]) && isset($this->Mask[$X][$Y])) {
return 0;
}
Expand Down Expand Up @@ -1585,7 +1574,7 @@ public function drawAlphaPixel($X, $Y, $Alpha, $R, $G, $B)
}

$C_Aliased = $this->allocateColor($this->Picture, $R, $G, $B, $Alpha);
imagesetpixel($this->Picture, $X, $Y, $C_Aliased);
imagesetpixel($this->Picture, (int) $X, (int) $Y, $C_Aliased);
}

/**
Expand Down

0 comments on commit 373786c

Please sign in to comment.