Skip to content

Commit

Permalink
Fix Implicit conversion from float
Browse files Browse the repository at this point in the history
Fix line render

fix EllipseRenderer

Wip
  • Loading branch information
yalagin committed May 3, 2024
1 parent 4c4bd5a commit cf6a146
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 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,16 @@ protected function renderStroke($image, $params, int $color, float $strokeWidth)
{
imagesetthickness($image, round($strokeWidth));

$width = $params['width'];
$width = (int)round($params['width']);
if ($width % 2 === 0) {
$width += 1;
}
$height = $params['height'];
$height = (int)round($params['height']);
if ($height % 2 === 0) {
$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']), (int)round($width), (int)round($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 cf6a146

Please sign in to comment.