@@ -934,7 +934,7 @@ def is_valid(cls, color: AnyRgba | AnyHsla | AnyHexa, allow_alpha: bool = True)
934934 )
935935
936936 @classmethod
937- def _parse_rgba (cls , color : AnyRgba ) -> rgba :
937+ def __parse_rgba (cls , color : AnyRgba ) -> rgba :
938938 """Internal method to parse a color to an RGBA object."""
939939 if isinstance (color , rgba ):
940940 return color
@@ -951,7 +951,7 @@ def _parse_rgba(cls, color: AnyRgba) -> rgba:
951951 raise ValueError (f"Could not parse RGBA color: { color !r} " )
952952
953953 @classmethod
954- def _parse_hsla (cls , color : AnyHsla ) -> hsla :
954+ def __parse_hsla (cls , color : AnyHsla ) -> hsla :
955955 """Internal method to parse a color to an HSLA object."""
956956 if isinstance (color , hsla ):
957957 return color
@@ -1007,11 +1007,11 @@ def to_rgba(cls, color: Rgba | Hsla | Hexa) -> rgba:
10071007 if isinstance (color , (hsla , hexa )):
10081008 return color .to_rgba ()
10091009 elif cls .is_valid_hsla (color ):
1010- return cls ._parse_hsla (color ).to_rgba ()
1010+ return cls .__parse_hsla (color ).to_rgba ()
10111011 elif cls .is_valid_hexa (color ):
10121012 return hexa (cast (str | int , color )).to_rgba ()
10131013 elif cls .is_valid_rgba (color ):
1014- return cls ._parse_rgba (color )
1014+ return cls .__parse_rgba (color )
10151015 raise ValueError (f"Could not convert color { color !r} to RGBA." )
10161016
10171017 @classmethod
@@ -1022,11 +1022,11 @@ def to_hsla(cls, color: Rgba | Hsla | Hexa) -> hsla:
10221022 if isinstance (color , (rgba , hexa )):
10231023 return color .to_hsla ()
10241024 elif cls .is_valid_rgba (color ):
1025- return cls ._parse_rgba (color ).to_hsla ()
1025+ return cls .__parse_rgba (color ).to_hsla ()
10261026 elif cls .is_valid_hexa (color ):
10271027 return hexa (cast (str | int , color )).to_hsla ()
10281028 elif cls .is_valid_hsla (color ):
1029- return cls ._parse_hsla (color )
1029+ return cls .__parse_hsla (color )
10301030 raise ValueError (f"Could not convert color { color !r} to HSLA." )
10311031
10321032 @classmethod
@@ -1037,9 +1037,9 @@ def to_hexa(cls, color: Rgba | Hsla | Hexa) -> hexa:
10371037 if isinstance (color , (rgba , hsla )):
10381038 return color .to_hexa ()
10391039 elif cls .is_valid_rgba (color ):
1040- return cls ._parse_rgba (color ).to_hexa ()
1040+ return cls .__parse_rgba (color ).to_hexa ()
10411041 elif cls .is_valid_hsla (color ):
1042- return cls ._parse_hsla (color ).to_hexa ()
1042+ return cls .__parse_hsla (color ).to_hexa ()
10431043 elif cls .is_valid_hexa (color ):
10441044 return color if isinstance (color , hexa ) else hexa (cast (str | int , color ))
10451045 raise ValueError (f"Could not convert color { color !r} to HEXA" )
@@ -1183,11 +1183,9 @@ def hex_int_to_rgba(cls, hex_int: int, preserve_original: bool = False) -> rgba:
11831183 else :
11841184 raise ValueError (f"Could not convert HEX integer 0x{ hex_int :X} to RGBA color." )
11851185
1186- @classmethod
1187- def _linearize_srgb (cls , c : float ) -> float :
1188- """Helper method to linearize sRGB component following the WCAG standard.\n
1189- ----------------------------------------------------------------------------
1190- - `c` -⠀the sRGB component value in range [0.0, 1.0] inclusive"""
1186+ @staticmethod
1187+ def __linearize_srgb (c : float ) -> float :
1188+ """Helper method to linearize sRGB component following the WCAG standard."""
11911189 if not (0.0 <= c <= 1.0 ):
11921190 raise ValueError (f"The 'c' parameter must be in range [0.0, 1.0] inclusive, got { c !r} " )
11931191
@@ -1229,14 +1227,14 @@ def luminance(
12291227 elif method == "bt601" :
12301228 luminance = 0.299 * _r + 0.587 * _g + 0.114 * _b
12311229 elif method == "wcag3" :
1232- _r = cls ._linearize_srgb (_r )
1233- _g = cls ._linearize_srgb (_g )
1234- _b = cls ._linearize_srgb (_b )
1230+ _r = cls .__linearize_srgb (_r )
1231+ _g = cls .__linearize_srgb (_g )
1232+ _b = cls .__linearize_srgb (_b )
12351233 luminance = 0.2126729 * _r + 0.7151522 * _g + 0.0721750 * _b
12361234 else :
1237- _r = cls ._linearize_srgb (_r )
1238- _g = cls ._linearize_srgb (_g )
1239- _b = cls ._linearize_srgb (_b )
1235+ _r = cls .__linearize_srgb (_r )
1236+ _g = cls .__linearize_srgb (_g )
1237+ _b = cls .__linearize_srgb (_b )
12401238 luminance = 0.2126 * _r + 0.7152 * _g + 0.0722 * _b
12411239
12421240 if output_type == int :
0 commit comments