Desaturate
Methods available are: hsv
, hsl
, hsv
, and hsp
. The input color type does not matter.
These methods are intended to provide alternative ways of modifying a color versus changing the values directly, which can make more sense.
.modify('saturate', {
amount: number, // optional, 0 - 1, defaults to 0.5
method: string, // optional, defaults to the original type or 'hsl' if type not directly supported
round: boolean, // optional, defaults to true
})
JavaScriptโ
const Color = require('chromaticity-color-utilities')
const color1 = Color.from('rgb', [255, 0, 255, 200]).modify('desaturate', {
method: 'hsl'
})
// rgb { r: 191, g: 64, b: 191, a: 200, bitDepth: 8, max: 255 }
const color2 = Color.from('rgb', [255, 0, 255, 200]).modify('desaturate', {
method: 'hsv',
amount: 0.5
})
// rgb { r: 255, g: 128, b: 255, a: 200, bitDepth: 8, max: 255 }
TypeScriptโ
import Color from 'chromaticity-color-utilities'
const color1: Color.rgb[] = Color.from('rgb', [255, 0, 255, 200])
.modify('desaturate', {
method: 'hsl',
amount: 0.5
})