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

Function hexToRgb

web/js/main.js:637–646  ·  view source on GitHub ↗
(hex)

Source from the content-addressed store, hash-verified

635
636// Palette File Parsers
637function hexToRgb(hex) {
638 hex = hex.replace(/^#/, '');
639 if (hex.length === 3) {
640 hex = hex.split('').map(c => c + c).join('');
641 }
642 if (hex.length !== 6) return null;
643 const n = parseInt(hex, 16);
644 if (isNaN(n)) return null;
645 return [(n >> 16) & 0xff, (n >> 8) & 0xff, n & 0xff];
646}
647
648function parseGplPalette(text, name) {
649 const lines = text.split(/\r?\n/);

Callers 3

parseJsonPaletteFunction · 0.85
parseHexPaletteFunction · 0.85
parseTxtPaletteFunction · 0.85

Calls 1

splitMethod · 0.45

Tested by

no test coverage detected