@nexys/math-ts
Version:
[](https://www.npmjs.com/package/@nexys/math-ts) [](https://travis-ci.com/github/Nexysweb/math-ts) [ • 772 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.toColor = (r, g, b) => {
const hg = g << 8;
const hb = b << 16;
return hg + hb + r;
};
exports.toUnitHex = (i) => {
if (i < 0 || i > 15) {
throw Error('bound conditions not respected');
}
if (i < 10) {
return String(i);
}
const arr = ['a', 'b', 'c', 'd', 'e', 'f'];
return arr[i - 10];
};
exports.toHex = (i) => {
const a = i % 16;
const b = (i >> 4) % 16;
const c = (i >> 8) % 16;
const d = (i >> 12) % 16;
const e = (i >> 16) % 16;
const f = (i >> 20) % 16;
return exports.toUnitHex(f) + exports.toUnitHex(e) + exports.toUnitHex(d) + exports.toUnitHex(c) + exports.toUnitHex(b) + exports.toUnitHex(a);
};