HSLColour class

A colour represented in the HSL (Hue, Saturation, Lightness) colour space.

HSL is a cylindrical model where:

  • Hue (0-360) is the colour angle on the colour wheel.
  • Saturation (0.0-1.0) is the intensity of the colour.
  • Lightness (0.0-1.0) ranges from black (0) through the pure colour (0.5) to white (1.0).

HSLColour implements Flutter's HSLColor interface, so you can use it anywhere Flutter expects an HSLColor.

Creating

final hsl = HSLColour(hue: 200, saturation: 0.8, lightness: 0.5);
final fromColour = HSLColour.fromColour(someColour);
final fromFlutter = HSLColour.fromColor(Colors.blue);

Converting

final colour = hsl.toColour();  // → Colour (ARGB)
final hsv = hsl.toHSV();        // → HSVColour
final color = hsl.toColor();     // → Flutter Color
Inheritance
Implemented types
Available extensions

Constructors

HSLColour({double alpha = 1.0, double hue = 360, double saturation = 1.0, double lightness = 1})
const
HSLColour.fromAHSL(double alpha, double hue, double saturation, double lightness)
const
HSLColour.fromColor(Color color)
factory
HSLColour.fromColour(Colour color)
factory
HSLColour.fromHSVColour(HSVColour hsv)
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.
no setteroverride
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
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
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
toHSLColour HSLColour

Available on HSLColor, provided by the Hslcolour extension

Returns this HSLColor as a Collect HSLColour.
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toColor() Color
Returns this HSL color in RGB.
override
toColour() Colour
Converts this colour to its Colour (ARGB) representation.
override
toHSL() HSLColour
Converts this colour to its HSLColour representation.
override
toHSV() HSVColour
Converts this colour to its HSVColour representation.
override
toString() String
A string representation of this object.
override
withAlpha(double alpha) HSLColour
Returns a copy of this color with the alpha parameter replaced with the given value.
override
withHue(double hue) HSLColour
Returns a copy of this color with the hue parameter replaced with the given value.
override
withLightness(double lightness) HSLColour
Returns a copy of this color with the lightness parameter replaced with the given value.
override
withSaturation(double saturation) HSLColour
Returns a copy of this color with the saturation parameter replaced with the given value.
override

Operators

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

Static Methods

lerp(HSLColour? a, HSLColour? b, double t) HSLColour?
Linearly interpolate between two HSLColors.
override