UNPKG

@remotion/studio

Version:

APIs for interacting with the Remotion Studio

18 lines (17 loc) 549 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.parseColor = void 0; const colorCache = new Map(); const parseColor = (color) => { const cached = colorCache.get(color); if (cached) return cached; const ctx = new OffscreenCanvas(1, 1).getContext('2d'); ctx.fillStyle = color; ctx.fillRect(0, 0, 1, 1); const [r, g, b, a] = ctx.getImageData(0, 0, 1, 1).data; const result = [r, g, b, a]; colorCache.set(color, result); return result; }; exports.parseColor = parseColor;