luminance method

Dimension luminance(
  1. Color color
)

Calculates the value of the luma without gamma correction

Parameters: color - a color object. Returns: percentage 0-100% Example: luminance(rgb(100, 200, 30)) Output: 65%

Implementation

Dimension luminance(Color color) {
  final luminance = (0.2126 * color.r / 255) +
      (0.7152 * color.g / 255) +
      (0.0722 * color.b / 255);

  return Dimension(luminance * color.alpha * 100, '%');

//    luminance: function (color) {
//        var luminance =
//            (0.2126 * color.rgb[0] / 255)
//                + (0.7152 * color.rgb[1] / 255)
//                + (0.0722 * color.rgb[2] / 255);
//
//        return new Dimension(luminance * color.alpha * 100, '%');
//    }
}