Skip to content

Commit

Permalink
fix: Remove implicit conversion from float to int (#234)
Browse files Browse the repository at this point in the history
Co-authored-by: Simon André <[email protected]>
  • Loading branch information
yalagin and smnandre authored Jun 28, 2024
1 parent 4c4bd5a commit dc2ef9c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
14 changes: 4 additions & 10 deletions src/Rasterization/Renderers/EllipseRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected function prepareRenderParams(array $options, Transform $transform, ?Fo
*/
protected function renderFill($image, $params, int $color): void
{
imagefilledellipse($image, $params['cx'], $params['cy'], $params['width'], $params['height'], $color);
imagefilledellipse($image, (int)round($params['cx']), (int)round($params['cy']), (int)round($params['width']), (int)round($params['height']), $color);
}

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

$width = $params['width'];
if ($width % 2 === 0) {
$width += 1;
}
$height = $params['height'];
if ($height % 2 === 0) {
$height += 1;
}
$width = (int)round($params['width']) | 1;
$height = (int)round($params['height']) | 1;

// imageellipse ignores imagesetthickness; draw arc instead
imagearc($image, $params['cx'], $params['cy'], $width, $height, 0, 360, $color);
imagearc($image, (int)round($params['cx']), (int)round($params['cy']), $width, $height, 0, 360, $color);
}
}
2 changes: 1 addition & 1 deletion src/Rasterization/Renderers/LineRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ protected function renderFill($image, $params, int $color): void
protected function renderStroke($image, $params, int $color, float $strokeWidth): void
{
imagesetthickness($image, round($strokeWidth));
imageline($image, $params['x1'], $params['y1'], $params['x2'], $params['y2'], $color);
imageline($image, (int)round($params['x1']), (int)round($params['y1']), (int)round($params['x2']), (int)round($params['y2']), $color);
}
}

0 comments on commit dc2ef9c

Please sign in to comment.