biContrastingColor method

Color biContrastingColor(
  1. {Color dark = Colors.black,
  2. Color light = Colors.white}
)

Implementation

Color biContrastingColor(
    {Color dark = Colors.black, Color light = Colors.white}) {
  ColorFloatStrip stripped = strip();
  double calcV = (0.299 * stripped.red +
      0.587 * stripped.green +
      0.223 * stripped.blue);
  double weight = 0.450;
  Debug().info("BC_Color calcV=$calcV for weight $weight");
  // thx to this stackoverflow answer for the weights: https://stackoverflow.com/a/3943023
  return calcV > weight // custom threshold
      ? dark
      : light;
}