@@ -22,15 +22,15 @@ public function getHexString(): string
2222 $ rgba = $ this ->asRgba ();
2323 if ($ rgba ->getAlpha () == 255 ) {
2424 return '# '
25- .str_pad (dechex ($ rgba ->getRed ()), 2 , '0 ' )
26- .str_pad (dechex ($ rgba ->getGreen ()), 2 , '0 ' )
27- .str_pad (dechex ($ rgba ->getBlue ()), 2 , '0 ' );
25+ .str_pad (dechex (( int ) round ( $ rgba ->getRed () )), 2 , '0 ' )
26+ .str_pad (dechex (( int ) round ( $ rgba ->getGreen () )), 2 , '0 ' )
27+ .str_pad (dechex (( int ) round ( $ rgba ->getBlue () )), 2 , '0 ' );
2828 } else {
2929 return '# '
30- .str_pad (dechex ($ rgba ->getRed ()), 2 , '0 ' )
31- .str_pad (dechex ($ rgba ->getGreen ()), 2 , '0 ' )
32- .str_pad (dechex ($ rgba ->getBlue ()), 2 , '0 ' )
33- .str_pad (dechex ($ rgba ->getAlpha ()), 2 , '0 ' );
30+ .str_pad (dechex (( int ) round ( $ rgba ->getRed () )), 2 , '0 ' )
31+ .str_pad (dechex (( int ) round ( $ rgba ->getGreen () )), 2 , '0 ' )
32+ .str_pad (dechex (( int ) round ( $ rgba ->getBlue () )), 2 , '0 ' )
33+ .str_pad (dechex (( int ) round ( $ rgba ->getAlpha () )), 2 , '0 ' );
3434 }
3535 }
3636
@@ -40,10 +40,10 @@ public function getHexString(): string
4040 public function getHslaString (): string
4141 {
4242 $ hslaColor = $ this ->asHsla ();
43- if ($ hslaColor ->getAlpha () == 255 ) {
44- return sprintf ('hsl(%s, %s%%, %s%%) ' , $ hslaColor ->getHue (), $ hslaColor ->getSaturation (), $ hslaColor ->getLightness ());
43+ if ($ hslaColor ->getAlpha () == 1 ) {
44+ return sprintf ('hsl(%s, %s%%, %s%%) ' , round ( $ hslaColor ->getHue ()), round ( $ hslaColor ->getSaturation ()), round ( $ hslaColor ->getLightness () ));
4545 } else {
46- return sprintf ('hsla(%s, %s%%, %s%%, %s) ' , $ hslaColor ->getHue (), $ hslaColor ->getSaturation (), $ hslaColor ->getLightness (), round ($ hslaColor ->getAlpha () / 255 , 2 ));
46+ return sprintf ('hsla(%s, %s%%, %s%%, %s) ' , round ( $ hslaColor ->getHue ()), round ( $ hslaColor ->getSaturation ()), round ( $ hslaColor ->getLightness ()) , round ($ hslaColor ->getAlpha (), 2 ));
4747 }
4848 }
4949
@@ -54,9 +54,9 @@ public function getRgbaString(): string
5454 {
5555 $ rgbColor = $ this ->asRgba ();
5656 if ($ rgbColor ->getAlpha () == 255 ) {
57- return sprintf ('rgb(%s, %s, %s) ' , $ rgbColor ->getRed (), $ rgbColor ->getGreen (), $ rgbColor ->getBlue ());
57+ return sprintf ('rgb(%s, %s, %s) ' , round ( $ rgbColor ->getRed ()), round ( $ rgbColor ->getGreen ()), round ( $ rgbColor ->getBlue () ));
5858 } else {
59- return sprintf ('rgba(%s, %s, %s, %s) ' , $ rgbColor ->getRed (), $ rgbColor ->getGreen (), $ rgbColor ->getBlue (), $ rgbColor ->getAlpha ());
59+ return sprintf ('rgba(%s, %s, %s, %s) ' , round ( $ rgbColor ->getRed ()), round ( $ rgbColor ->getGreen ()), round ( $ rgbColor ->getBlue () ), $ rgbColor ->getAlpha ());
6060 }
6161 }
6262
@@ -97,11 +97,11 @@ public function withMixedColor(ColorInterface $color, int $weight = 50): ColorIn
9797 }
9898
9999 /**
100- * @param int $delta
100+ * @param float $delta
101101 *
102102 * @return ColorInterface
103103 */
104- public function withAdjustedLightness (int $ delta ): ColorInterface
104+ public function withAdjustedLightness (float $ delta ): ColorInterface
105105 {
106106 $ hslaColor = $ this ->asHsla ();
107107 $ lightness = $ hslaColor ->getLightness () + $ delta ;
@@ -121,11 +121,11 @@ public function withAdjustedLightness(int $delta): ColorInterface
121121 }
122122
123123 /**
124- * @param int $delta
124+ * @param float $delta
125125 *
126126 * @return ColorInterface
127127 */
128- public function withAdjustedSaturation (int $ delta ): ColorInterface
128+ public function withAdjustedSaturation (float $ delta ): ColorInterface
129129 {
130130 $ hslaColor = $ this ->asHsla ();
131131 $ saturation = $ hslaColor ->getSaturation () + $ delta ;
@@ -145,11 +145,11 @@ public function withAdjustedSaturation(int $delta): ColorInterface
145145 }
146146
147147 /**
148- * @param int $delta
148+ * @param float $delta
149149 *
150150 * @return ColorInterface
151151 */
152- public function withAdjustedHue (int $ delta ): ColorInterface
152+ public function withAdjustedHue (float $ delta ): ColorInterface
153153 {
154154 $ hslaColor = $ this ->asHsla ();
155155 $ hue = ($ hslaColor ->getHue () + $ delta ) % 360 ;
0 commit comments