miniBill/elm-oklch/1.0.0

NOTE: the latest version is 1.1.0

Color.Oklab

Types

type alias Oklab =
{ lightness : Float
, a : Float
, b : Float
, alpha : Float
}

A color in the Oklab space.

  • lightness ranges from 0.0 to 1.0 (inclusive),
  • a (green/red) ranges from approximatively -0.3 to +0.3,
  • b (blue/yellow) ranges from approximatively -0.3 to +0.3,
  • alpha ranges from 0.0 to 1.0 (inclusive).

Creating colors

oklab : Float -> Float -> Float -> Oklab

Builds a color from its lightness, a (green/red) and b (blue/yellow) components.

  • lightness ranges from 0.0 to 1.0 (inclusive),
  • a (green/red) ranges from approximatively -0.3 to +0.3,
  • b (blue/yellow) ranges from approximatively -0.3 to +0.3.
oklaba : Float -> Float -> Float -> Float -> Oklab

Builds a color from its lightness, a (green/red), b (blue/yellow) and alpha components.

  • lightness ranges from 0.0 to 1.0 (inclusive),
  • a (green/red) ranges from approximatively -0.3 to +0.3,
  • b (blue/yellow) ranges from approximatively -0.3 to +0.3,
  • alpha ranges from 0.0 to 1.0 (inclusive).

Conversions

fromColor : Color -> Oklab

Convert a color from Color (sRGB) to Oklab.

toColor : Oklab -> Color

Convert a color from Oklab to Color (sRGB).

fromLinearRGB : LinearRGB -> Oklab

Converts a color from linear RGB (red, green, blue) to Oklab.

The components should be between 0.0 and 1.0 (inclusive).

toLinearRGB : Oklab -> LinearRGB

Converts a color from Oklab to linear RGB (red, green, blue).

The output components get clipped at 0 to avoid NaNs.