ZetaColorExtensions extension
Extensions on Color to brighten, lighten, darken and blend colors and can get a shade for gradients.
Some of the extensions are rewrites of TinyColor's functions https://pub.dev/packages/tinycolor. See LICENSE-3RD-PARTY.
The TinyColor algorithms have also been modified to use Flutter's HSLColor class instead of the custom one in the TinyColor lib. The functions from TinyColor re-implemented as Color extensions here are brighten, lighten and darken. They are used for color calculations in ZetaColorScheme, but also exposed for reuse.
Another frequently used extension is blend and blendAlpha used to blend two colors using alpha as a percentage or as an 8-bit int alpha value. This extension is used to calculate branded surface colors used by ZetaColorScheme's branded surfaces and for automatic dark color schemes from a light scheme.
The getShadeColor extension is less frequently used and when used, typically used to color makes colors shades for gradient AppBars, with default setting to not change black and white.
- on
Properties
- hexCode → String
-
Available on Color, provided by the ZetaColorExtensions extension
Return uppercase Flutter style hex code string of the color.no setter - isDark → bool
-
Available on Color, provided by the ZetaColorExtensions extension
Returns true if the color's brightness is Brightness.dark, else false.no setter - isLight → bool
-
Available on Color, provided by the ZetaColorExtensions extension
Returns true if the color's brightness is Brightness.light, else false.no setter - lightness → double
-
Available on Color, provided by the ZetaColorExtensions extension
Gets lightness of color.no setter - onColor → Color
-
Available on Color, provided by the ZetaColorExtensions extension
This getter returns appropriate contrast color based on a given color. It will return a color chosen according to the brightness of this color.no setter - zetaColorSwatch → ZetaColorSwatch
-
Available on Color, provided by the ZetaColorExtensions extension
ZetaColorSwatch
is a color swatch utility to produce different shades of a primary color, following a specific progression of lightness and darkness.no setter
Methods
-
adjustContrast(
{required Color on, required double target, int maxIterations = 1000, double epsilon = 0.1}) → Color -
Available on Color, provided by the ZetaColorExtensions extension
Adjusts the color to a specific contrast target. -
blend(
Color input, [int amount = 10]) → Color -
Available on Color, provided by the ZetaColorExtensions extension
Blend in the given input Color with a percentage of alpha. -
blendAlpha(
Color input, [int alpha = 0x0A]) → Color -
Available on Color, provided by the ZetaColorExtensions extension
Blend in the given input Color with an alpha value. -
brighten(
[int amount = 10]) → Color -
Available on Color, provided by the ZetaColorExtensions extension
Brightens the color with the given integer percentage amount. Defaults to 10%. -
contrastRatio(
Color b) → double -
Available on Color, provided by the ZetaColorExtensions extension
Calculates the contrast ratio between the current color and the given colorb
. -
darken(
[int amount = 10]) → Color -
Available on Color, provided by the ZetaColorExtensions extension
Darkens the color with the given integer percentage amount. Defaults to 10%. -
ensureAccessibility(
{required Color on, ZetaContrast standard = ZetaContrast.aa}) → Color -
Available on Color, provided by the ZetaColorExtensions extension
Adjusts the current color to meet the specified accessibility standardstandard
when set against theon
color. -
generateSwatch(
{int primary = kZetaSwatchPrimaryIndex, Map< int, double> targetContrasts = kZetaSwatchTargetContrasts, Color background = ZetaColorBase.white, bool adjustPrimary = true}) → Map<int, Color> -
Available on Color, provided by the ZetaColorExtensions extension
Generates a color swatch for this color. A color swatch is a map with integer keys indexing to Color objects, typically used for design themes. -
getShadeColor(
{int shadeValue = 15, bool lighten = true, bool keepBlack = true, bool keepWhite = true}) → Color -
Available on Color, provided by the ZetaColorExtensions extension
The getShadeColor extension is used to make a color darker or lighter, theshadeValue
defines the amount in % that the shade should be changed. -
lighten(
[int amount = 10]) → Color -
Available on Color, provided by the ZetaColorExtensions extension
Lightens the color with the given integer percentage amount. Defaults to 10%. -
withLightness(
double percentage) → Color -
Available on Color, provided by the ZetaColorExtensions extension
Applies lightness percentage to color.