Skip to main content

Saturate

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', [128, 64, 128, 200]).modify('saturate', {
method: 'hsl'
})
// rgb { r: 160, g: 32, b: 160, a: 200, bitDepth: 8, max: 255 }
const color2 = Color.from('rgb', [128, 64, 128, 200]).modify('saturate', {
method: 'hsv',
amount: 0.5
})
// rgb { r: 128, g: 32, b: 128, a: 200, bitDepth: 8, max: 255 }

TypeScriptโ€‹

import Color from 'chromaticity-color-utilities'

const color1: Color.rgb[] = Color.from('rgb', [128, 64, 128, 200])
.modify('saturate', {
method: 'hsl',
amount: 0.5
})