UNPKG

hex-argb-converter

Version:

You can convert hex color to argb number and convert argb number to hex color

26 lines (25 loc) 691 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.argbToHex = void 0; function redFromArgb(argb) { return (argb >> 16) & 255; } function greenFromArgb(argb) { return (argb >> 8) & 255; } function blueFromArgb(argb) { return argb & 255; } function argbToHex(argb) { const r = redFromArgb(argb); const g = greenFromArgb(argb); const b = blueFromArgb(argb); const outParts = [r.toString(16), g.toString(16), b.toString(16)]; for (const [i, part] of outParts.entries()) { if (part.length === 1) { outParts[i] = "0" + part; } } return "#" + outParts.join(""); } exports.argbToHex = argbToHex;