RgbColor class Null safety

A color in the sRGB color space.

The sRGB color space contains channels for red, green, and blue.

RgbColor stores RGB values as nums privately in order to avoid a loss of precision when converting between color spaces, but has getters set for red, green, and blue that return the rounded int values. The precise values can returned as a list with the toPreciseList() method.

Inheritance
Annotations

Constructors

RgbColor(num red, num green, num blue, [int alpha = 255])
A color in the sRGB color space.
const
RgbColor.extrapolate(List<double> values)
Constructs a RgbColor from a list of rgb values on a 0 to 1 scale.
factory
RgbColor.from(ColorModel color)
Constructs a RgbColor from color.
factory
RgbColor.fromHex(String hex)
Constructs a RgbColor from a RGB hex color.
factory
RgbColor.fromList(List<num> values)
Constructs a RgbColor from a list of rgb values.
factory
RgbColor.random({int minRed = 0, int maxRed = 255, int minGreen = 0, int maxGreen = 255, int minBlue = 0, int maxBlue = 255, int? seed})
Generates a RgbColor at random.
factory

Properties

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

Methods

castTo(ColorModel other) ColorModel
Converts this color to other's color space.
inherited
convert(ColorModel other) RgbColor
Converts other to this color's color space.
override
cooler(num amount, {bool relative = true}) RgbColor
Adjusts the hue of this color by amount towards 270 degrees, capping the value at 270.
override
copyWith({num? red, num? green, num? blue, int? alpha}) RgbColor
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) RgbColor
Interpolates to step between this and end.
override
lerpTo(ColorModel color, int steps, {ColorSpace? colorSpace, bool excludeOriginalColors = false}) List<RgbColor>
Returns the interpolated steps between this color and color.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
rotateHue(num amount) RgbColor
Rotates the hue of this color by amount in degrees.
override
toCmykColor() CmykColor
Converts this to the CMYK color space.
inherited
toFactoredList() List<double>
Returns a fixed-length list containing the red, green, and blue values factored to be on 0 to 1 scale.
toFactoredListWithAlpha() List<double>
Returns a fixed-length list containing the red, green, blue, and alpha values factored to be on 0 to 1 scale.
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<int>
Returns a fixed-length list containing the red, green, and blue values.
override
toListWithAlpha() List<num>
Returns a fixed-length list containing the red, green, blue, and alpha values.
override
toOklabColor() OklabColor
Converts this to the Oklab color space.
inherited
toPreciseList() List<num>
Returns a fixed-length list containing the precise red, green, and blue values.
toPreciseListWithAlpha() List<num>
Returns a fixed-length list containing the precise red, green, blue, and alpha values.
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}) RgbColor
Adjusts the hue of this color by amount towards 90 degrees, capping the value at 90.
override
withAlpha(int alpha) RgbColor
Returns this RgbColor modified with the provided alpha value.
override
withChroma(double chroma) RgbColor
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) RgbColor
Returns this RgbColor modified with the provided hue value.
override
withOpacity(double opacity) RgbColor
Returns this ColorModel with the provided opacity value.
override
withValues(List<num> values) RgbColor
Returns a color in this color's color space with the values provided.
override

Operators

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