HSLColor class

A color represented using alpha, hue, saturation, and lightness.

An HSLColor is represented in a parameter space that's based up human perception of colored light. The representation is useful for some color computations (e.g., combining colors of light), because interpolation and picking of colors as red, green, and blue channels doesn't always produce intuitive results.

HSL is a perceptual color model, placing fully saturated colors around a circle (conceptually) at a lightness of ​0.5, with a lightness of 0.0 being completely black, and a lightness of 1.0 being completely white. As the lightness increases or decreases from 0.5, the apparent saturation decreases proportionally (even though the saturation parameter hasn't changed).

See also:

  • HSVColor, a color that uses a color space based on human perception of pigments (e.g. paint and printer's ink).
  • HSV and HSL Wikipedia article, which this implementation is based upon.
Annotations
  • @immutable

Constructors

HSLColor.fromAHSL(double alpha, double hue, double saturation, double lightness)
Creates a color. [...]
const
HSLColor.fromColor(Color color)
Creates an HSLColor from an RGB Color. [...]
factory

Properties

alpha double
Alpha, from 0.0 to 1.0. The describes the transparency of the color. A value of 0.0 is fully transparent, and 1.0 is fully opaque.
final
hashCode int
The hash code for this object. [...]
read-only, override
hue double
Hue, from 0.0 to 360.0. Describes which color of the spectrum is represented. A value of 0.0 represents red, as does 360.0. Values in between go through all the hues representable in RGB. You can think of this as selecting which color filter is placed over a light.
final
lightness double
Lightness, from 0.0 to 1.0. The lightness of a color describes how bright a color is. A value of 0.0 indicates black, and 1.0 indicates white. You can think of this as the intensity of the light behind the filter. As the lightness approaches 0.5, the colors get brighter and appear more saturated, and over 0.5, the colors start to become less saturated and approach white at 1.0.
final
saturation double
Saturation, from 0.0 to 1.0. This describes how colorful the color is. 0.0 implies a shade of grey (i.e. no pigment), and 1.0 implies a color as vibrant as that hue gets. You can think of this as the purity of the color filter over the light.
final
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

toColor() Color
Returns this HSL color in RGB.
toString() String
Returns a string representation of this object.
override
withAlpha(double alpha) HSLColor
Returns a copy of this color with the alpha parameter replaced with the given value.
withHue(double hue) HSLColor
Returns a copy of this color with the hue parameter replaced with the given value.
withLightness(double lightness) HSLColor
Returns a copy of this color with the lightness parameter replaced with the given value.
withSaturation(double saturation) HSLColor
Returns a copy of this color with the saturation parameter replaced with the given value.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited

Operators

operator ==(dynamic other) bool
The equality operator. [...]
override

Static Methods

lerp(HSLColor a, HSLColor b, double t) HSLColor
Linearly interpolate between two HSLColors. [...]