generated from roboflow/template-python
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
Description
Description
Many users provide 4- or 8-digit hexadecimal color codes that include an alpha channel (e.g., #FF00FF80 for 50% transparent magenta). The library should be extended to support these formats natively, without introducing any changes to the existing public API.
-
Parse 4- and 8-digit hex anywhere a color hex is allowed (
Color.from_hex,ColorPalette, annotatorcolor= arguments, etc.) -
Extend the Color dataclass with an optional a field (default 255):
from supervision import sv sv.Color(r=255, g=0, b=255, a=128)
-
If
a != 255,as_hex()returns#RRGGBBAA; otherwise it keeps#RRGGBB.
Addas_rgba()helper; keepas_rgb()unchanged. -
Update
_validate_color_hexto allow lengths3,4,6,8; raiseValueErrorotherwise. -
Annotators keep their signatures. When a
Colorcarriesalphamake them draw withopacity.
Additional
- Please share a Google Colab with minimal code to test the new feature. We know it's additional work, but it will speed up the review process. The reviewer must test each change. Setting up a local environment to do this is time-consuming. Please ensure that Google Colab can be accessed without any issues (make it public). Thank you! 🙏🏻
- Provide full unit-test coverage matching existing test style.
- Update the library docs (docstrings, mkdocs) to reflect the new API.