stripAlpha

ColorPicker
stable

Remove the alpha channel from a colour object when the stripAlpha flag is true. Returns the original object unchanged when the flag is false.

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

color
required
any
A colour object such as THSVA, TRGBA or THSLA. The function shallow-clones it before deleting the `a` property so the original is not mutated.
stripAlpha
required
boolean
When true the `a` key is removed from the cloned colour. When false the original colour is returned as-is.

API

Return value

The value returned by this util.

A shallow clone of the colour without the `a` property (stripAlpha=true), or the unchanged colour object (stripAlpha=false).

Usage

Examples

Ready-to-paste usage snippets.

Stripping alpha from an HSV colour

typescript