Skip to content

Commit dc2ef9c

Browse files
yalaginsmnandre
andauthored
fix: Remove implicit conversion from float to int (#234)
Co-authored-by: Simon André <[email protected]>
1 parent 4c4bd5a commit dc2ef9c

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

src/Rasterization/Renderers/EllipseRenderer.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ protected function prepareRenderParams(array $options, Transform $transform, ?Fo
4242
*/
4343
protected function renderFill($image, $params, int $color): void
4444
{
45-
imagefilledellipse($image, $params['cx'], $params['cy'], $params['width'], $params['height'], $color);
45+
imagefilledellipse($image, (int)round($params['cx']), (int)round($params['cy']), (int)round($params['width']), (int)round($params['height']), $color);
4646
}
4747

4848
/**
@@ -52,16 +52,10 @@ protected function renderStroke($image, $params, int $color, float $strokeWidth)
5252
{
5353
imagesetthickness($image, round($strokeWidth));
5454

55-
$width = $params['width'];
56-
if ($width % 2 === 0) {
57-
$width += 1;
58-
}
59-
$height = $params['height'];
60-
if ($height % 2 === 0) {
61-
$height += 1;
62-
}
55+
$width = (int)round($params['width']) | 1;
56+
$height = (int)round($params['height']) | 1;
6357

6458
// imageellipse ignores imagesetthickness; draw arc instead
65-
imagearc($image, $params['cx'], $params['cy'], $width, $height, 0, 360, $color);
59+
imagearc($image, (int)round($params['cx']), (int)round($params['cy']), $width, $height, 0, 360, $color);
6660
}
6761
}

src/Rasterization/Renderers/LineRenderer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ protected function renderFill($image, $params, int $color): void
5151
protected function renderStroke($image, $params, int $color, float $strokeWidth): void
5252
{
5353
imagesetthickness($image, round($strokeWidth));
54-
imageline($image, $params['x1'], $params['y1'], $params['x2'], $params['y2'], $color);
54+
imageline($image, (int)round($params['x1']), (int)round($params['y1']), (int)round($params['x2']), (int)round($params['y2']), $color);
5555
}
5656
}

0 commit comments

Comments
 (0)