UNPKG

661 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.rgb2hex = void 0;
4var consts_1 = require("./consts");
5var clamp_1 = require("./clamp");
6/** Converts RGB components to a hex color string (without # prefix). */
7function rgb2hex(r, g, b) {
8 return [_rgbToPaddedHex(r), _rgbToPaddedHex(g), _rgbToPaddedHex(b)].join('');
9}
10exports.rgb2hex = rgb2hex;
11/** Converts an RGB component to a 0-padded hex component of length 2. */
12function _rgbToPaddedHex(num) {
13 num = clamp_1.clamp(num, consts_1.MAX_COLOR_RGB);
14 var hex = num.toString(16);
15 return hex.length === 1 ? '0' + hex : hex;
16}
17//# sourceMappingURL=rgb2hex.js.map
\No newline at end of file