---
title: "API Reference"
---

## Color spaces

The _colorspace_ package supports the following color spaces
(see also [Color Spaces: Classes and Utilities](/articles/color_spaces.qmd)).
These classes all inherit from one superclass `colorobject` which provides
a series of useful methods. 

::: {.tbl-borderless}

| Class | Description |
|-------|-------------|
| [`polarLUV`](/man/colorspace.colorlib.polarLUV.qmd), [`HCL`](/man/colorspace.colorlib.HCL.qmd) | Create polarLUV (=HCL) colors |
| [`CIELUV`](/man/colorspace.colorlib.CIELUV.qmd) | Create CIELUV colors |
| [`CIELAB`](/man/colorspace.colorlib.CIELAB.qmd) | Create CIELAB colors |
| [`CIEXYZ`](/man/colorspace.colorlib.CIEXYZ.qmd) | Create CIEXYZ colors |
| [`RGB`](/man/colorspace.colorlib.RGB.qmd) | Create RGB colors |
| [`sRGB`](/man/colorspace.colorlib.sRGB.qmd) | Create sRGB colors |
| [`HLS`](/man/colorspace.colorlib.HLS.qmd) | Create HLS colors |
| [`HSV`](/man/colorspace.colorlib.HSV.qmd) | Create HSV colors |
| [`hexcols`](/man/colorspace.colorlib.hexcols.qmd) | Create hex colors |

: {tbl-colwidths="[30,70]"}
:::

::: {.tbl-borderless}

| Method   | Description |
|----------|-----------------------------------|
| `.to()`         | Convert colors between color spaces |
| `.colors()`     | Extract HEX colors |
| `.hclplot()`    | Palette plot in HCL space |
| `.specplot()`   | Color spectrum plot |
| `.swatchplot()` | Palette swatch plot |

: {tbl-colwidths="[30,70]"}
:::




## HCL-based palettes

_colorspace_ comes with a variety of pre-defined palettes (see
[`hcl_palettes`](/man/colorspace.hcl_palettes.hcl_palettes.qmd) and
[HCL-Based Color Palettes](articles/hcl_palettes.qmd)) which can either be used
as is, or customized. In addition, fully customized palettes can be created/defined.
All classes inherit from the superclass `hclpalette` providing the same functionality. The
main methods are listed below.

::: {.tbl-borderless}

| Class | Description |
|-------|-------------|
| [`qualitative_hcl`](/man/colorspace.palettes.qualitative_hcl.qmd) | Qualitative HCL Color Palettes |
| [`sequential_hcl`](/man/colorspace.palettes.sequential_hcl.qmd) | Sequential HCL Color Palettes |
| [`diverging_hcl`](/man/colorspace.palettes.diverging_hcl.qmd) | Diverging HCL Color Palettes |
| [`rainbow_hcl`](/man/colorspace.palettes.rainbow_hcl.qmd) | HCL Based Rainbow Palette |
| [`heat_hcl`](/man/colorspace.palettes.heat_hcl.qmd) | HCL Based Heat Color Palette |
| [`terrain_hcl`](/man/colorspace.palettes.terrain_hcl.qmd) | HCL Based Terrain Color Palette |
| [`diverging_hsv`](/man/colorspace.palettes.diverging_hcl.qmd) | Diverging HCL Color Palettes |

: {tbl-colwidths="[30,70]"}
:::

::: {.tbl-borderless}

| Method   | Description |
|----------|-----------------------------------|
| `.colors()`     | Draw colors from the palette |
| `.cmap()`       | Create matplotlib compatible colormap |
| `.hclplot()`    | Palette plot in HCL space |
| `.specplot()`   | Color spectrum plot |
| `.swatchplot()` | Palette swatch plot |
| `.show_settings()` | Show palette settings (trajectory definition) |

: {tbl-colwidths="[30,70]"}
:::


## Custom palettes

Besides HCL-based color palettes which are defined by their trajectories trough the HCL space
(see [HCL-Based Color Palettes: Construction Details](/articles/hcl_palettes.qmd#construction-details)),
_colorspace_ provides the [`palette`](/man/colorspace.palettes.palette.qmd) class to set up
custom palettes based on a fixed number of colors, providing similar functionality
as the HCL-based palettes. The main methods are listed below.

::: {.tbl-borderless}

| Class | Description |
|-------|-------------|
| [`palette`](/man/colorspace.palettes.palette.qmd) | Create custom color palette |

: {tbl-colwidths="[30,70]"}
:::

::: {.tbl-borderless}

| Method   | Description |
|----------|-----------------------------------|
| `.colors()`     | Draw colors from the palette |
| `.cmap()`       | Create matplotlib compatible colormap |
| `.hclplot()`    | Palette plot in HCL space |
| `.specplot()`   | Color spectrum plot |
| `.swatchplot()` | Palette swatch plot |
| `.show_settings()` | Show palette settings (trajectory definition) |

: {tbl-colwidths="[30,70]"}
:::



## Palette visualization and assessment

To visually assess sets of colors (or color palettes), _colorspace_ provides a
series of plotting function. These are also interfaced by the identically named
methods of the different palette classes listed above.

::: {.tbl-borderless}

| Function  | Description |
|-----------|-------------|
| [`swatchplot`](man/colorspace.swatchplot.swatchplot.qmd) | Palette Swatch Plot |
| [`specplot`](man/colorspace.specplot.specplot.qmd) | Color Spectrum Plot |
| [`demoplot`](man/colorspace.demos.demoplot.qmd) | Create Demo Plots |
| [`hclplot`](man/colorspace.hclplot.hclplot.qmd) | Palette Plot in HCL Space |

: {tbl-colwidths="[30,70]"}
:::



## GUI for choosing color palettes

::: {.tbl-borderless}

|   |   |
|---|---|
| [`choose_palette`](man/colorspace.choose_palette.choose_palette.qmd) | Graphical User Interface for Choosing HCL Color Palettes |

: {tbl-colwidths="[30,70]"}
:::


## Color vision defficiency emulation

::: {.tbl-borderless}

|   |   |
|---|---|
| [`deutan`](man/colorspace.CVD.deutan.qmd), [`protan`](man/colorspace.CVD.protan.qmd), [`tritan`](man/colorspace.CVD.tritan.qmd) | Simulate Color Vision Deficiency |
| [`cvd_image`](man/colorspace.cvd_image.cvd_image.qmd) | Check Images for Color Constraints |

: {tbl-colwidths="[30,70]"}
:::


## Color manipulation and utilities

::: {.tbl-borderless}

| Function | Description |
|----------|-------------|
| [`desaturate`](man/colorspace.CVD.desaturate.qmd) | Desaturate Colors by Chroma Removal in HCL Space |
| [`max_chroma`](man/colorspace.utils.max_chroma.qmd) | Compute Maximum Chroma for Given Hue and Luminance in HCL |
| [`contrast_ratio`](man/colorspace.utils.contrast_ratio.qmd) | W3C Contrast Ratio |
| [`compare_colors`](man/colorspace.colorlib.compare_colors.qmd) | Compare colors/check for equality |
| [`check_hex_colors`](man/colorspace.utils.check_hex_colors) | Checking HEX Color Validity |
| [`lighten`](man/colorspace.utils.lighten.qmd), [`darken`](man/colorspace.utils.darken.qmd) | Algorithmically Lighten or Darken Colors |
| [`mixcolor`](man/colorspace.utils.mixcolor.qmd) | Compute the Convex Combination of Two Colors |
| [`extract_transparency`](man/colorspace.utils.extract_transparency.qmd), [`adjust_transparency`](man/colorspace.utils.adjust_transparency.qmd) | Adjust or Extract Transparency of Colors |

: {tbl-colwidths="[30,70]"}
:::


