This implements the gamut mapping algorithm according to CSS Level 4 specification.
from coloraide.gamut import Fit
from coloraide.util import NaN
class OklchChroma(Fit):
"""Lch chroma gamut mapping class."""
from coloraide.contrast import ColorContrast | |
class Weber(ColorContrast): | |
"""Weber contrast.""" | |
NAME = "weber" | |
@classmethod | |
def contrast(cls, color1, color2, **kwargs): | |
"""Contrast.""" |
inputs = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'] | |
colors = Color(inputs[0]).steps(inputs[1:], steps=20, space='srgb') | |
colors | |
ColorRow() | |
[c.cvd('achromatopsia').clip() for c in colors] | |
ColorRow() | |
[c.cvd('brettel-protan').clip() for c in colors] | |
ColorRow() | |
[c.cvd('brettel-deutan').clip() for c in colors] | |
ColorRow() |
from coloraide.gamut import Fit, clip_channels | |
from coloraide.util import NaN | |
class OklchChroma(Fit): | |
"""Lch chroma gamut mapping class.""" | |
NAME = "oklch-chroma" | |
EPSILON = 0.0001 |
print('---- Gamut Mapping with Oklch ----') | |
class Color2(Color): | |
FIT = "oklch-chroma" | |
colors = ['green', 'blue'] | |
Color2.interpolate(colors, space="lab") | |
Color2.interpolate(colors, space="lch") | |
Color2.interpolate(colors, space="oklab") | |
Color2.interpolate(colors, space="oklch") | |
print('---- Gamut Mapping with CIE LCH ----') |
from coloraide.gamut import Fit, clip_channels | |
from coloraide.util import NaN | |
class OklchChroma(Fit): | |
"""Lch chroma gamut mapping class.""" | |
NAME = "oklch-chroma" | |
EPSILON = 0.0001 |
This implements the gamut mapping algorithm according to CSS Level 4 specification.
from coloraide.gamut import Fit
from coloraide.util import NaN
class OklchChroma(Fit):
"""Lch chroma gamut mapping class."""
from coloraide.distance.delta_e_76 import DE76 | |
from coloraide.gamut.fit_lch_chroma import LchChroma | |
from coloraide import Color as OrigColor | |
class DEOK(DE76): | |
"""Delta E OK class.""" | |
NAME = "ok" | |
SPACE = "oklab" |
ColorAide's documentation is rendered with Python Markdown and Pymdown Extensions. The color notebook implements a dynamic, live environment allowing for on the fly page rendering. This is accomplished by using Pyodide to execute the required Python modules to render the desired pages.
Pages can contain most Markdown but also special code blocks called playgrounds. These playgrounds are simple fenced code blocks that allow for a user to input and execute Python code. Each playground exposes access to ColorAide allowing for sandboxes to explore the features of ColorAide. Additionally, the playgrounds will search for color objects, interpolation objects, and color
""" | |
Okhsl class. | |
Translation to/from Oklab is licenced under MIT by the original author, all | |
other code also licensed under MIT: Copyright (c) 2021 Isaac Muse. | |
---- Oklab license ---- | |
Copyright (c) 2021 Björn Ottosson |
""" | |
HSLuv and HPLuv. | |
Adapted to Python and ColorAide by Isaac Muse (2021) | |
--- HSLuv Conversion Algorithm --- | |
Copyright (c) 2012-2021 Alexei Boronine | |
Copyright (c) 2016 Florian Dormont |