excolor.palette
- excolor.palette.generate_palette(color, n=10, mode='superellipse', power=3, debug=False)[source]
Generates a palette of darker shades and lighter tints for a given color.
- Parameters:
color (Any) – The input color. Can be a named color, hex string, or a tuple/list in RGB, RGBA, HSV, HLS, or OKLCH format.
n (int, default=10) – The number of colors to generate in the palette.
mode (str, default='superellipse') – The mode of the palette generation. Can be ‘superellipse’, ‘circle’, or ‘linear’.
power (float, default=2) – The power of superellipse to traverse the RGB space from black to white.
debug (bool, default=False) – If True, show the debug information.
- Returns:
A list of colors in the palette.
- Return type:
- excolor.palette.generate_primary_palette(color, mode='superellipse', power=3, fmt='hex', fname=None)[source]
Generates a broad palette suitable for primary CSS styling.
This function creates a 9-color palette balanced around the mid-tones.
- Parameters:
color (Any) – The base color for the palette.
mode (str, default='superellipse') – The palette generation mode.
power (float, default=3) – The superellipse power.
fmt (str, default='hex') – The output format for the palette if printed/saved (‘hex’, ‘rgb’, ‘hls’, ‘oklch’).
fname (str, optional) – The filename to save the CSS palette to. If None, prints to stdout.
- Returns:
A list of 9 hex color strings.
- Return type:
- excolor.palette.generate_background_palette(color, mode='superellipse', power=3, fmt='hex', fname=None)[source]
Generates a palette of darker shades suitable for backgrounds.
This function creates a 9-color palette weighted towards darker tones.
- Parameters:
color (Any) – The base color for the palette.
mode (str, default='superellipse') – The palette generation mode.
power (float, default=3) – The superellipse power.
fmt (str, default='hex') – The output format for the palette if printed/saved (‘hex’, ‘rgb’, ‘hls’, ‘oklch’).
fname (str, optional) – The filename to save the CSS palette to. If None, prints to stdout.
- Returns:
A list of 9 hex color strings.
- Return type:
- excolor.palette.generate_foreground_palette(color, mode='superellipse', power=3, fmt='hex', fname=None)[source]
Generates a palette of lighter tints suitable for foregrounds.
This function creates a 9-color palette weighted towards lighter tones.
- Parameters:
color (Any) – The base color for the palette.
mode (str, default='superellipse') – The palette generation mode.
power (float, default=3) – The superellipse power.
fmt (str, default='hex') – The output format for the palette if printed/saved (‘hex’, ‘rgb’, ‘hls’, ‘oklch’).
fname (str, optional) – The filename to save the CSS palette to. If None, prints to stdout.
- Returns:
A list of 9 hex color strings.
- Return type:
- excolor.palette.generate_stepwise_palette(cmap, n=6, exclude_extreme=True, use_hue=True)[source]
Generates a stepwise color palette from a given colormap.
This function analyzes the hue and lightness trends of a colormap to create a perceptually balanced, stepwise palette. It identifies whether the colormap is sequential or diverging and samples colors accordingly.
- Parameters:
cmap (str or matplotlib.colors.Colormap) – The input colormap to generate the palette from.
n (int, default=6) – The desired number of colors in the final palette.
exclude_extreme (bool, default=True) – If True, removes the very light and very dark colors from the ends of the palette.
use_hue (bool, default=True) – If True, considers hue trends in addition to lightness to determine the colormap structure.
- Returns:
A list of hex color strings representing the generated palette.
- Return type: