getContrastColor method

Color getContrastColor(
  1. Color color
)

Calculates the contrast color for a given color.

Implementation

Color getContrastColor(Color color) {
  int d = color.computeLuminance() > 0.5 ? 0 : 255;

  return Color.fromARGB(color.alpha, d, d, d);
}