@@ -38,19 +38,19 @@ def _is_hex(x: str) -> bool:
3838
3939def _parse_hex (color_code : str ) -> TypeRGBAFloats :
4040 return (
41- _color_byte_to_normalized_float (int (color_code [1 :3 ], 16 )),
42- _color_byte_to_normalized_float (int (color_code [3 :5 ], 16 )),
43- _color_byte_to_normalized_float (int (color_code [5 :7 ], 16 )),
41+ _color_int_to_float (int (color_code [1 :3 ], 16 )),
42+ _color_int_to_float (int (color_code [3 :5 ], 16 )),
43+ _color_int_to_float (int (color_code [5 :7 ], 16 )),
4444 1.0 ,
4545 )
4646
4747
48- def _color_byte_to_normalized_float (x : Union [int , float ]) -> float :
48+ def _color_int_to_float (x : Union [int , float ]) -> float :
4949 """Convert an integer between 0 and 255 to a float between 0. and 1.0"""
5050 return x / 255.0
5151
5252
53- def _color_normalized_float_to_byte_int (x : float ) -> int :
53+ def _color_float_to_int (x : float ) -> int :
5454 """Convert a float between 0. and 1.0 to an integer between 0 and 255"""
5555 return int (x * 255.9999 )
5656
@@ -78,7 +78,7 @@ def _parse_color_as_numerical_sequence(x: Union[tuple, list]) -> TypeRGBAFloats:
7878 raise ValueError (f"Color sequence should have 3 or 4 elements, not { len (x )} ." )
7979 conversion_function : Callable = float
8080 if 1 < max (x ) <= 255 :
81- conversion_function = _color_byte_to_normalized_float
81+ conversion_function = _color_int_to_float
8282 if min (x ) < 0 or max (x ) > 255 :
8383 raise ValueError ("Color components should be between 0.0 and 1.0 or 0 and 255." )
8484 color : List [float ] = [conversion_function (value ) for value in x ]
@@ -175,9 +175,7 @@ def rgba_bytes_tuple(self, x: float) -> TypeRGBAInts:
175175 """Provides the color corresponding to value `x` in the
176176 form of a tuple (R,G,B,A) with int values between 0 and 255.
177177 """
178- return tuple (
179- _color_normalized_float_to_byte_int (u ) for u in self .rgba_floats_tuple (x )
180- ) # type: ignore
178+ return tuple (_color_float_to_int (u ) for u in self .rgba_floats_tuple (x )) # type: ignore
181179
182180 def rgb_bytes_tuple (self , x : float ) -> TypeRGBInts :
183181 """Provides the color corresponding to value `x` in the
0 commit comments