MCPcopy Create free account
hub / github.com/SpaceZephyr/myskill / rgbToHex

Function rgbToHex

pptx/scripts/html2pptx.js:263–270  ·  view source on GitHub ↗
(rgbStr)

Source from the content-addressed store, hash-verified

261 const pxToInch = (px) => px / PX_PER_IN;
262 const pxToPoints = (pxStr) => parseFloat(pxStr) * PT_PER_PX;
263 const rgbToHex = (rgbStr) => {
264 // Handle transparent backgrounds by defaulting to white
265 if (rgbStr === 'rgba(0, 0, 0, 0)' || rgbStr === 'transparent') return 'FFFFFF';
266
267 const match = rgbStr.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
268 if (!match) return 'FFFFFF';
269 return match.slice(1).map(n => parseInt(n).toString(16).padStart(2, '0')).join('');
270 };
271
272 const extractAlpha = (rgbStr) => {
273 const match = rgbStr.match(/rgba\((\d+),\s*(\d+),\s*(\d+),\s*([\d.]+)\)/);

Callers 3

parseBoxShadowFunction · 0.85
parseInlineFormattingFunction · 0.85
extractSlideDataFunction · 0.85

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected