UNPKG

@hiddentao/clockwork-engine

Version:

A TypeScript/PIXI.js game engine for deterministic, replayable games with built-in rendering

26 lines (25 loc) 567 B
/** * Color Utilities * * Shared functions for color conversion and manipulation. */ /** * Convert RGB object to hex number * * @param rgb RGB color object * @returns Hex color number */ export function rgbToHex(rgb) { return (rgb.r << 16) | (rgb.g << 8) | rgb.b; } /** * Normalize color to hex number * * Accepts either hex number or RGB object and returns hex number. * * @param color Color in either format * @returns Hex color number */ export function normalizeColor(color) { return typeof color === "number" ? color : rgbToHex(color); }