lib-colors
Version:
Simple node.js library for work with colors
13 lines (12 loc) • 491 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.grayToString = grayToString;
const alpha_is_set_helper_1 = require("../../helpers/alpha_is_set.helper");
function grayToString(gray) {
const { g, a } = { ...gray };
const grayscale = Math.round((g / 100) * 255);
if ((0, alpha_is_set_helper_1.alphaIsSet)(a)) {
return `rgba(${grayscale},${grayscale},${grayscale},${a})`;
}
return `rgb(${grayscale},${grayscale},${grayscale})`;
}