LchGamut

object LchGamut

sRGB gamut clipping using binary search to find the edge of the gamut for a specific color.

Out-of-gamut colors are mapped using gamut intersection in a 2D plane, and hue is always preserved. Lightness and chroma are changed depending on the clip method; see ClipMethod for details.

OklabGamut has the same goal, but this is a generalized solution that works with any color space or color appearance model with brightness/lightness, chroma/colorfulness, and hue attributes. It's not as fast as OklabGamut and lacks methods that use the lightness of the maximum chroma in the hue plane, but is much more flexible.

Currently, only ZCAM is supported, but the underlying algorithm implementation may be exposed in the future as it is portable to other color spaces and appearance models.

Types

ClipMethod
Link copied to clipboard
enum ClipMethod : Enum<LchGamut.ClipMethod>

Functions

clipToLinearSrgb
Link copied to clipboard
fun Zcam.clipToLinearSrgb(method: LchGamut.ClipMethod = ClipMethod.PRESERVE_LIGHTNESS, alpha: Double = 0.05): LinearSrgb

Convert this ZCAM color to linear sRGB, and clip it to sRGB gamut boundaries if it's not already within gamut.