UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

14 lines (11 loc) 435 B
import { assert } from "../assert.js"; /** * Convert a decimal value to hex * @param {number} x generally expects b byte value, 0-255 * @returns {string} zero-padded value, for example instead of "0", will return "00" and instead of "F" will return "0F" */ export function dec2hex(x) { assert.greaterThanOrEqual(x, 0); const hex = Math.round(x).toString(16); return hex.length === 1 ? "0" + hex : hex; }