grayscale function

RGBA grayscale (RGBA color)

Implementation

RGBA grayscale(RGBA color) {
  int avg = clampPixel(
      (0.2126 * color.red + 0.7152 * color.green + 0.0722 * color.blue)
          .round());
  return new RGBA(
    red: avg,
    green: avg,
    blue: avg,
    alpha: color.alpha,
  );
}