OklabColor class

A color in the Oklab color space.

The Oklab color space contains channels for lightness, a (red and green opponent values), and b (blue and yellow opponent values.)

See: https://bottosson.github.io/posts/oklab/

Inheritance
Annotations
  • @immutable

Constructors

OklabColor(double lightness, double a, double b, [int alpha = 255])
A color in the Oklab color space.
const
OklabColor.from(ColorModel color)
Constructs an OklabColor from color.
factory
OklabColor.fromHex(String hex)
Constructs an OklabColor from a RGB hex color.
factory
OklabColor.fromList(List<num> values)
Constructs an OklabColor from a list of lab values.
factory
OklabColor.random({double minLightness = 0.0, double maxLightness = 1.0, double minA = 0.0, double maxA = 1.0, double minB = 0.0, double maxB = 1.0, int? seed})
Generates an OklabColor at random.
factory

Properties

a double
The red to green opponent color value.
final
alpha int
The alpha value of this color.
finalinherited
b double
The yellow to blue opponent color value.
final
chroma double
Calculates a value representing this color's lightness on a linear scale.
no setterinherited
hashCode int
The hash code for this object.
no setteroverride
hex String
Returns this as a hexidecimal string.
no setterinherited
hue num
Gets the hue value of this color.
no setterinherited
inverted OklabColor
Inverts the values of this ColorModel, excluding alpha, in its own color space.
no setteroverride
isBlack bool
Returns true if this color is pure black.
no setteroverride
isMonochromatic bool
Returns true if this color is monochromatic.
no setteroverride
isWhite bool
Returns true if this color is pure white.
no setteroverride
lightness double
Lightness represents the black to white value.
final
opacity double
The alpha value as a double normalized to a 0.0 to 1.0 range.
no setterinherited
opposite OklabColor
Returns the color with the hue opposite of this colors'.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
saturation num
The saturation value of this color. Color spaces without a saturation value will be converted to HSL to retrieve the value.
no setterinherited

Methods

castTo(ColorModel other) ColorModel
Converts this color to other's color space.
inherited
convert(ColorModel other) OklabColor
Converts other to this color's color space.
override
cooler(num amount, {bool relative = true}) OklabColor
Adjusts the hue of this color by amount towards 270 degrees, capping the value at 270.
override
copyWith({double? lightness, double? a, double? b, int? alpha}) OklabColor
Returns a copy of this color modified with the provided values.
override
distanceTo(ColorModel color) double
Returns the distance between this color's hue and color's hue in degrees.
inherited
equals(ColorModel color) bool
Compares colors in the RGB color space.
inherited
interpolate(ColorModel end, double step) OklabColor
Interpolates to step between this and end.
override
lerpTo(ColorModel color, int steps, {ColorSpace? colorSpace, bool excludeOriginalColors = false}) List<OklabColor>
Returns the interpolated steps between this color and color.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
rotateHue(num amount) OklabColor
Rotates the hue of this color by amount in degrees.
override
rotateHueRad(double amount) OklabColor
Rotates the hue of this color by amount in radians.
override
toCmykColor() CmykColor
Converts this to the CMYK color space.
inherited
toHsbColor() HsbColor
Converts this to the HSB color space.
inherited
toHsiColor() HsiColor
Converts this to the HSI color space.
inherited
toHslColor() HslColor
Converts this to the HSL color space.
inherited
toHspColor() HspColor
Converts this to the HSP color space.
inherited
toLabColor() LabColor
Converts this to the LAB color space.
inherited
toList() List<double>
Returns a fixed-length list containing the lightness, a, and b values, in that order.
override
toListWithAlpha() List<num>
Returns a fixed-length list containing the lightness, a, b, and alpha values, in that order.
override
toOklabColor() OklabColor
Converts this to the Oklab color space.
override
toRgbColor() RgbColor
Converts this to the RGB color space.
override
toString() String
A string representation of this object.
override
toXyzColor() XyzColor
Converts this to the XYZ color space.
inherited
warmer(num amount, {bool relative = true}) OklabColor
Adjusts the hue of this color by amount towards 90 degrees, capping the value at 90.
override
withAlpha(int alpha) OklabColor
Returns this OklabColor modified with the provided alpha value.
override
withChroma(double chroma) OklabColor
Converts this color to the Oklab color space, calculates and applies a new lightness value from the proivded chroma value, and converts it back to the original color space.
override
withHue(num hue) OklabColor
Returns this OklabColor modified with the provided hue value.
override
withOpacity(double opacity) OklabColor
Returns this ColorModel with the provided opacity value.
override
withValues(List<num> values) OklabColor
Returns a color in this color's color space with the values provided.
override

Operators

operator ==(Object other) bool
The equality operator.
override