Skip to content

How to confine manipulated colors to sRGB space #415

@cfra

Description

@cfra

Hello, when using OKLCH lightness to adjust an rgb color, the resulting color for some cases contains negative coordinates:

In [48]: Color('#FECE00').set('oklch.lightness', 0.75)
Out[48]: color(srgb 0.84223 0.65716 -0.23291 / 1)

I guess this is to be expected because, as far as I understand it, sRGB cannot represent all coordinates representable by the OKLCH color space.

However, I am wondering if there is a way to ensure the resulting color is limited to the nearest neighbor in sRGB color space.

Metadata

Metadata

Assignees

No one assigned

    Labels

    S: triageIssue needs triage.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions