UNPKG

lib-colors

Version:

Simple node.js library for work with colors

12 lines (11 loc) 313 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.rgbToGray = rgbToGray; function rgbToGray(rgb) { const { r, g, b, a } = { ...rgb }; const grayscale = Math.round(((0.299 * r + 0.587 * g + 0.114 * b) * 100) / 255); return { g: grayscale, a, }; }