/** * General helper utilities */ /** * Deep copy an object using JSON serialization * @param {any} obj - Object to deep copy * @returns {any} Deep copy of the object */ export function deepCopy(obj) { return JSON.parse(JSON.stringify(obj)); } /** * Convert hex color string to RGB array [0-1] * @param {string} hex - Hex color string (e.g., "#ff0000" or "ff0000") * @returns {number[]} RGB array with values in range [0, 1] */ export function hexToRgb(hex) { const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); if (!result) return [0.0, 0.0, 0.0]; return [ parseInt(result[1], 16) / 255.0, parseInt(result[2], 16) / 255.0, parseInt(result[3], 16) / 255.0 ]; }