Open bernhard-42 opened 3 months ago
def get_rgba(color, alpha=None, def_color=None): color = def_color if color is None else color if hasattr(color, "toTuple"): # CadQery Color *rgb, a = color.toTuple() elif hasattr(color, "percentage"): # Alg123d Color rgb, a = color.percentage, color.a elif hasattr(color, "to_tuple"): # Build123d *rgb, a = color.to_tuple() elif isinstance(color, Quantity_ColorRGBA): # OCP ocp_rgb = color.GetRGB() rgb = (ocp_rgb.Red(), ocp_rgb.Green(), ocp_rgb.Blue()) a = color.Alpha() elif isinstance(color, str) or isinstance(color, (tuple, list)): col = Color(color) rgb, a = col.percentage, col.a else: raise ValueError(f"Unknown color input {color} ({type(color)}")
Add
elif isintance(color, Iterable): *rgb, a = list(color)
or so ...
Add
or so ...