diff --git a/src/BaseColor.php b/src/BaseColor.php index db3591f..1e698f0 100644 --- a/src/BaseColor.php +++ b/src/BaseColor.php @@ -76,11 +76,11 @@ public function __construct(string $code) } /** - * @param int $percent + * @param float $percent * * @return mixed */ - public function saturate(int $percent) + public function saturate(float $percent) { $color = $this->toHsl(); $saturation = $this->clamp(($color->saturation() + $percent) / 100); @@ -88,11 +88,11 @@ public function saturate(int $percent) } /** - * @param int $percent + * @param float $percent * * @return mixed */ - public function desaturate(int $percent) + public function desaturate(float $percent) { $color = $this->toHsl(); $saturation = $this->clamp(($color->saturation() - $percent) / 100); @@ -108,11 +108,11 @@ public function grayscale() } /** - * @param int $percent + * @param float $percent * * @return mixed */ - public function brighten(int $percent) + public function brighten(float $percent) { $percent *= -1; $color = $this->toRgb(); @@ -123,11 +123,11 @@ public function brighten(int $percent) } /** - * @param int $percent + * @param float $percent * * @return mixed */ - public function lighten(int $percent) + public function lighten(float $percent) { $color = $this->toHsl(); $lightness = $this->clamp(($color->lightness() + $percent) / 100); @@ -135,11 +135,11 @@ public function lighten(int $percent) } /** - * @param int $percent + * @param float $percent * * @return mixed */ - public function darken(int $percent) + public function darken(float $percent) { $color = $this->toHsl(); $lightness = $this->clamp(($color->lightness() - $percent) / 100); @@ -166,11 +166,11 @@ public function isDark() } /** - * @param int $percent + * @param float $percent * * @return mixed */ - public function spin(int $percent) + public function spin(float $percent) { $color = $this->toHsl(); $hue = ($color->hue() + $percent) % 360; @@ -183,7 +183,7 @@ public function spin(int $percent) * * @return mixed */ - public function mix(BaseColor $color, int $percent = 50) + public function mix(BaseColor $color, float $percent = 50) { $first = $this->toRgb(); $second = $color->toRgb(); @@ -197,7 +197,7 @@ public function mix(BaseColor $color, int $percent = 50) /** * @link https://github.com/less/less.js/blob/master/packages/less/src/less/functions/color.js * - * @param int $percent + * @param float $percent * * @return mixed */ @@ -211,7 +211,7 @@ public function tint($percent = 50) /** * @link https://github.com/less/less.js/blob/master/packages/less/src/less/functions/color.js * - * @param int $percent + * @param float $percent * * @return mixed */ diff --git a/src/Traits/AlphaTrait.php b/src/Traits/AlphaTrait.php index 063349f..e32c3c2 100644 --- a/src/Traits/AlphaTrait.php +++ b/src/Traits/AlphaTrait.php @@ -17,7 +17,7 @@ trait AlphaTrait public function alpha($alpha = null): float|static { if ($alpha !== null) { - $this->alpha = min($alpha, 1); + $this->alpha = min(round($alpha, 2), 1); return $this; } return $this->alpha;