An abstract base class representing a color that can be transformed between different color spaces.
ColorDerivative provides a unified interface for working with colors in various color spaces (HSV, HSL, RGB) while maintaining transformation capabilities. This is particularly useful in color picker implementations where users may want to work with different color models.
The class supports:
- Conversion between HSV, HSL, and RGB color spaces
- Individual channel manipulation (hue, saturation, value/lightness, red, green, blue, opacity)
- Preserving the internal color representation when transforming
Example:
// Create from a Flutter Color
final derivative = ColorDerivative.fromColor(Colors.blue);
// Modify saturation
final desaturated = derivative.changeToHSVSaturation(0.5);
// Convert back to Color
final newColor = desaturated.toColor();
Constructors
- ColorDerivative()
-
Creates a const ColorDerivative.
const
- ColorDerivative.fromHSL(HSLColor color)
-
Creates a ColorDerivative from an HSLColor.
constfactory
- ColorDerivative.fromHSV(HSVColor color)
-
Creates a ColorDerivative from an HSVColor.
constfactory
Properties
- blue → int
-
Gets the blue component in RGB color space, ranging from 0 to 255.
no setter
- green → int
-
Gets the green component in RGB color space, ranging from 0 to 255.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hslHue → double
-
Gets the hue component in HSL color space, ranging from 0.0 to 360.0.
no setter
- hslSat → double
-
Gets the saturation component in HSL color space, ranging from 0.0 to 1.0.
no setter
- hslVal → double
-
Gets the lightness component in HSL color space, ranging from 0.0 to 1.0.
no setter
- hsvHue → double
-
Gets the hue component in HSV color space, ranging from 0.0 to 360.0.
no setter
- hsvSat → double
-
Gets the saturation component in HSV color space, ranging from 0.0 to 1.0.
no setter
- hsvVal → double
-
Gets the value (brightness) component in HSV color space, ranging from 0.0 to 1.0.
no setter
- opacity → double
-
Gets the opacity (alpha) value of this color, ranging from 0.0 to 1.0.
no setter
- red → int
-
Gets the red component in RGB color space, ranging from 0 to 255.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
changeToColor(
Color color) → ColorDerivative -
Changes this color to the specified
colorwhile preserving the internal color space representation. -
changeToColorBlue(
double blue) → ColorDerivative - Changes the blue component of this color in RGB color space.
-
changeToColorGreen(
double green) → ColorDerivative - Changes the green component of this color in RGB color space.
-
changeToColorRed(
double red) → ColorDerivative - Changes the red component of this color in RGB color space.
-
changeToHSL(
HSLColor color) → ColorDerivative -
Changes this color to the specified
colorin HSL color space. -
changeToHSLHue(
double hue) → ColorDerivative - Changes the hue component of this color in HSL color space.
-
changeToHSLLightness(
double lightness) → ColorDerivative - Changes the lightness component of this color in HSL color space.
-
changeToHSLSaturation(
double saturation) → ColorDerivative - Changes the saturation component of this color in HSL color space.
-
changeToHSV(
HSVColor color) → ColorDerivative -
Changes this color to the specified
colorin HSV color space. -
changeToHSVAlpha(
double alpha) → ColorDerivative - Changes the alpha (opacity) component of this color in HSV color space.
-
changeToHSVHue(
double hue) → ColorDerivative - Changes the hue component of this color in HSV color space.
-
changeToHSVSaturation(
double saturation) → ColorDerivative - Changes the saturation component of this color in HSV color space.
-
changeToHSVValue(
double value) → ColorDerivative - Changes the value (brightness) component of this color in HSV color space.
-
changeToOpacity(
double alpha) → ColorDerivative - Changes the opacity (alpha) value of this color.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toColor(
) → Color - Converts this color derivative to a Flutter Color.
-
toHSLColor(
) → HSLColor - Converts this color derivative to an HSLColor.
-
toHSVColor(
) → HSVColor - Converts this color derivative to an HSVColor.
-
toString(
) → String -
A string representation of this object.
inherited
-
transform(
ColorDerivative old) → ColorDerivative -
Transforms this color derivative to match the internal representation of
old.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
fromColor(
Color color) → ColorDerivative - Creates a ColorDerivative from a Flutter Color using HSV color space internally.