Returns a list of all CSS named colors. See
https://developer.mozilla.org/en-US/docs/Web/CSS/named-color
Parameters
Returns
The list of all CSS named colors.
Expand source code
@staticmethod
def CSSNamedColors():
Returns a list of all CSS named colors. See https://developer.mozilla.org/en-US/docs/Web/CSS/named-color
Parameters
----------
Returns
-------
The list of all CSS named colors.
# List of CSS named colors
css_named_colors = [
"aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige", "bisque", "black", "blanchedalmond",
"blue", "blueviolet", "brown", "burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue",
"cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod", "darkgray", "darkgreen", "darkgrey",
"darkkhaki", "darkmagenta", "darkolivegreen", "darkorange", "darkorchid", "darkred", "darksalmon",
"darkseagreen", "darkslateblue", "darkslategray", "darkslategrey", "darkturquoise", "darkviolet", "deeppink",
"deepskyblue", "dimgray", "dimgrey", "dodgerblue", "firebrick", "floralwhite", "forestgreen", "fuchsia",
"gainsboro", "ghostwhite", "gold", "goldenrod", "gray", "green", "greenyellow", "grey", "honeydew", "hotpink",
"indianred", "indigo", "ivory", "khaki", "lavender", "lavenderblush", "lawngreen", "lemonchiffon", "lightblue",
"lightcoral", "lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightgrey", "lightpink",
"lightsalmon", "lightseagreen", "lightskyblue", "lightslategray", "lightslategrey", "lightsteelblue",
"lightyellow", "lime", "limegreen", "linen", "magenta", "maroon", "mediumaquamarine", "mediumblue",
"mediumorchid", "mediumpurple", "mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise",
"mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin", "navajowhite", "navy", "oldlace",
"olive", "olivedrab", "orange", "orangered", "orchid", "palegoldenrod", "palegreen", "paleturquoise",
"palevioletred", "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue", "purple", "rebeccapurple",
"red", "rosybrown", "royalblue", "saddlebrown", "salmon", "sandybrown", "seagreen", "seashell", "sienna",
"silver", "skyblue", "slateblue", "slategray", "slategrey", "snow", "springgreen", "steelblue", "tan",
"teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white", "whitesmoke", "yellow", "yellowgreen"
return css_named_colors
def
PlotlyColor
(
color, alpha=1.0, useAlpha=False)
Returns a plotly color string based on the input list of [r, g, b] or [r, g, b, a]. If your list is [r, g, b], you can optionally specify an alpha value
Parameters
color
:
list
The input color list. This is assumed to be in the format [r, g, b] or [r, g, b, a]
alpha
:
float
, optional
The transparency value. 0.0 means the color is fully transparent, 1.0 means the color is fully opaque. The default is 1.0.
useAlpha
:
bool
, optional
If set to True, the returns list includes the alpha value as a fourth element in the list.
Returns
The plotly color string.
Expand source code
@staticmethod
def PlotlyColor(color, alpha=1.0, useAlpha=False):
Returns a plotly color string based on the input list of [r, g, b] or [r, g, b, a]. If your list is [r, g, b], you can optionally specify an alpha value
Parameters
----------
color : list
The input color list. This is assumed to be in the format [r, g, b] or [r, g, b, a]
alpha : float , optional
The transparency value. 0.0 means the color is fully transparent, 1.0 means the color is fully opaque. The default is 1.0.
useAlpha : bool , optional
If set to True, the returns list includes the alpha value as a fourth element in the list.
Returns
-------
The plotly color string.
if not isinstance(color, list):
print("Color.PlotlyColor - Error: The input color parameter is not a valid list. Returning None.")
return None
if len(color) < 3:
print("Color.PlotlyColor - Error: The input color parameter contains less than the minimum three elements. Returning None.")
return None
if len(color) == 4:
alpha = color[3]
alpha = min(max(alpha, 0), 1)
if alpha < 1:
useAlpha = True
if useAlpha:
return "rgba("+str(color[0])+","+str(color[1])+","+str(color[2])+","+str(alpha)+")"
return "rgb("+str(color[0])+","+str(color[1])+","+str(color[2])+")"
def
RGBToHex
(
rgb)
Converts RGB color values to a hexadecimal color string.
Parameters
rgb
:
tuple
A tuple containing three integers representing the RGB values.
Returns
A hexadecimal color string in the format '#RRGGBB'.
Expand source code
@staticmethod
def RGBToHex(rgb):
Converts RGB color values to a hexadecimal color string.
Parameters
----------
rgb : tuple
A tuple containing three integers representing the RGB values.
Returns
-------
A hexadecimal color string in the format '#RRGGBB'.
if not isinstance(rgb, list):
print("Color.RGBToHex - Error: The input rgb parameter is not a valid list. Returning None.")
return None
r, g, b = rgb
hex_value = "#{:02x}{:02x}{:02x}".format(r, g, b)
return hex_value.upper()