utils/wcag_luminance
library
Functions
-
averageLuminanceOfRegion({required Uint8List rgba, required int width, required int height, required Rect pixelRect, required Color background})
→ double?
-
Average WCAG relative luminance of
rgba (a rawRgba-format image
buffer, width×height) within pixelRect (in pixel coordinates of
that buffer). Fully transparent pixels (alpha < 0.02) are evaluated as
background instead of their own (meaningless) color, mirroring how a
viewer would actually perceive them. Returns null if pixelRect doesn't
cover any pixel.
-
wcagContrastRatio(double luminanceA, double luminanceB)
→ double
-
The WCAG contrast ratio between two relative luminances, in
[1, 21].
Order of arguments does not matter.
-
wcagLuminance(double r, double g, double b)
→ double
-
WCAG 2.x relative luminance from non-linear sRGB channels in
[0, 1].
-
wcagLuminanceOfColor(Color color)
→ double
-
The WCAG relative luminance of an opaque
color (alpha is ignored —
composite over its background first if it isn't already opaque).