Darken
Methods available are: rgb
, hsv
/value
, hsl
/lightness
, hsi
/intensity
, hsp
/perceived
, cmyk
, and cmyk2
/black
. rgb
and cmyk
modify all values.
These methods are intended to provide alternative ways of modifying a color versus changing the values directly, which can make more sense.
.modify('darken', {
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 color2 = Color.from('rgb', [255, 0, 255, 200]).modify('darken', {
method: 'lightness',
})
// rgb { r: 128, g: 0, b: 128, a: 200, bitDepth: 8, max: 255 }
const color2 = Color.from('rgb', [100, 0, 100]).modify('darken', {
method: 'hsp',
amount: 0.5
})
// rgb { r: 52, g: 0, b: 52, a: 255, bitDepth: 8, max: 255 }
TypeScriptโ
import Color from 'chromaticity-color-utilities'
const color4: Color.rgb[] = Color.from('rgb', [255, 0, 255, 200])
.modify('darken', { method: 'lightness' })