UNPKG
lib-colors
Version:
latest (0.2.1)
0.2.1
0.2.0
0.1.1
0.1.0
0.0.2
0.0.1
Simple node.js library for work with colors
github.com/fwmakc/lib-colors
fwmakc/lib-colors
lib-colors
/
dist
/
rgb
/
helpers
/
rgb_to_gray.helper.js
12 lines
(11 loc)
•
313 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
"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, }; }