UNPKG

@nexys/math-ts

Version:

[![npm version](https://badge.fury.io/js/%40nexys%2Fmath-ts.svg)](https://www.npmjs.com/package/@nexys/math-ts) [![TavisCI](https://travis-ci.com/Nexysweb/tableau-wdc-react.svg?branch=master)](https://travis-ci.com/github/Nexysweb/math-ts) [![Deployment](

27 lines (26 loc) 772 B
"use strict"; 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); };