ColorExtensions extension

Extension on Color to provide additional utility methods for color manipulation and analysis.

on

Methods

blend(Color other, double ratio) Color

Available on Color, provided by the ColorExtensions extension

Blends the current color with another color using a specified blending ratio.
complementary() Color

Available on Color, provided by the ColorExtensions extension

Generates a complementary color by inverting the current color.
darken(double factor) Color

Available on Color, provided by the ColorExtensions extension

Returns a darker shade of the current color.
getBrightness() double

Available on Color, provided by the ColorExtensions extension

Calculates the brightness of the color.
getLuminance() double

Available on Color, provided by the ColorExtensions extension

Returns the luminance of the color.
isDark() bool

Available on Color, provided by the ColorExtensions extension

Determines whether the given color is "dark".
isLight() bool

Available on Color, provided by the ColorExtensions extension

Determines whether the given color is "light".
lighten(double factor) Color

Available on Color, provided by the ColorExtensions extension

Returns a lighter shade of the current color.
toGrayscale() Color

Available on Color, provided by the ColorExtensions extension

Converts the current color to a grayscale color by averaging the red, green, and blue channels.
toHex({bool leadingHashSign = true, bool includeAlpha = false}) String

Available on Color, provided by the ColorExtensions extension

You can customize the output by setting leadingHashSign to include or omit the '#' symbol. You can also include the alpha (transparency) value in the hex string by setting includeAlpha.
withValues({required double opacity}) Color

Available on Color, provided by the ColorExtensions extension

Returns the Color as a semi-transparent version of itself based on the provided opacity factor.

Static Methods

fromHex(String hexString) Color

Available on Color, provided by the ColorExtensions extension

Converts the Color object to a hexadecimal string representation. The output can be customized to include or exclude the leading '#' symbol and the alpha (transparency) value.