Pote.Converters (Pote v3.0.0)

Copy Markdown View Source

Color conversion module.

Convenience functions that delegate to the individual converter modules (Pote.Converters.RGB, Pote.Converters.HSL, etc.).

Rounding policy

Internal converter functions preserve full float precision. Rounding is only applied at the final public API boundary (e.g. output formatting, string representation). This ensures roundtrip conversions (e.g. RGB → HSL → RGB) are as lossless as possible given the inherent quantization of 8-bit RGB.

Summary

Functions

Converts CMYK to RGB.

Converts a hex string to RGB.

Converts HSL to RGB.

Converts HSV to RGB.

Converts HWB to RGB.

Converts RGB to CMYK.

Converts RGB to hex string.

Converts RGB to HSL.

Converts RGB to HSV.

Converts RGB to HWB.

Converts RGB to the nearest XTerm256 index.

Converts an XTerm256 index (0-255) to RGB.

Functions

cmyk_to_rgb(cmyk)

@spec cmyk_to_rgb(Pote.cmyk()) :: Pote.rgb()

Converts CMYK to RGB.

hex_to_rgb(hex)

@spec hex_to_rgb(Pote.hex()) :: {:ok, Pote.rgb()} | {:error, :invalid_hex_format}

Converts a hex string to RGB.

hsl_to_rgb(hsl)

@spec hsl_to_rgb(Pote.hsl()) :: Pote.rgb()

Converts HSL to RGB.

hsv_to_rgb(hsv)

@spec hsv_to_rgb(Pote.hsv()) :: Pote.rgb()

Converts HSV to RGB.

hwb_to_rgb(hwb)

@spec hwb_to_rgb(Pote.hwb()) :: Pote.rgb()

Converts HWB to RGB.

rgb_to_cmyk(rgb)

@spec rgb_to_cmyk(Pote.rgb()) :: Pote.cmyk()

Converts RGB to CMYK.

rgb_to_hex(rgb)

@spec rgb_to_hex(Pote.rgb()) :: Pote.hex()

Converts RGB to hex string.

rgb_to_hsl(rgb)

@spec rgb_to_hsl(Pote.rgb()) :: Pote.hsl()

Converts RGB to HSL.

rgb_to_hsv(rgb)

@spec rgb_to_hsv(Pote.rgb()) :: Pote.hsv()

Converts RGB to HSV.

rgb_to_hwb(rgb)

@spec rgb_to_hwb(Pote.rgb()) :: Pote.hwb()

Converts RGB to HWB.

rgb_to_xterm256(rgb)

@spec rgb_to_xterm256(Pote.rgb()) :: Pote.xterm256()

Converts RGB to the nearest XTerm256 index.

xterm256_to_rgb(index)

@spec xterm256_to_rgb(Pote.xterm256()) :: Pote.rgb()

Converts an XTerm256 index (0-255) to RGB.