MCPcopy Create free account
hub / github.com/32comic/image2pixel-web / parseHexPalette

Function parseHexPalette

web/js/main.js:757–768  ·  view source on GitHub ↗
(text, name)

Source from the content-addressed store, hash-verified

755}
756
757function parseHexPalette(text, name) {
758 const lines = text.split(/\r?\n/);
759 const colors = [];
760 for (const line of lines) {
761 const trimmed = line.trim();
762 if (!trimmed || trimmed.startsWith('#') && trimmed.length <= 1) continue;
763 const rgb = hexToRgb(trimmed);
764 if (rgb) colors.push(rgb);
765 }
766 if (colors.length < 2) throw new Error('Palette must contain at least 2 colors');
767 return { id: name.replace(/\.[^.]+$/, ''), displayName: name.replace(/\.[^.]+$/, ''), colors };
768}
769
770function parseTxtPalette(text, name) {
771 const lines = text.split(/\r?\n/);

Callers 1

parsePaletteFileFunction · 0.85

Calls 2

hexToRgbFunction · 0.85
splitMethod · 0.45

Tested by

no test coverage detected