diff --git a/src/Pixel.js b/src/Pixel.js index 546fd3b..545f3f6 100644 --- a/src/Pixel.js +++ b/src/Pixel.js @@ -14,25 +14,33 @@ module.exports = class Pixel { this.hex = hex; this.matches = []; - const usedPalettes = []; - - items.forEach((item) => { - item.hexColours.forEach(({ value }, index) => { - if (value.toLowerCase().includes(hex.toLowerCase())) { - if (!usedPalettes.includes(item.name)) { - this.matches.push({ - palette: { - name: item.name, - description: item.description, - }, - position: position(index), - }); - - usedPalettes.push(item.name); + this.isTransparent = hex === '0'; + + if (!this.isTransparent) { + delete this.isTransparent; + } + + if (!this.isTransparent) { + const usedPalettes = []; + + items.forEach((item) => { + item.hexColours.forEach(({ value }, index) => { + if (value.toLowerCase().includes(hex.toLowerCase())) { + if (!usedPalettes.includes(item.name)) { + this.matches.push({ + palette: { + name: item.name, + description: item.description, + }, + position: position(index), + }); + + usedPalettes.push(item.name); + } } - } + }); }); - }); + } } get palettes() { diff --git a/test/unit/companion.spec.js b/test/unit/companion.spec.js index 8fcb09b..ba55f12 100644 --- a/test/unit/companion.spec.js +++ b/test/unit/companion.spec.js @@ -17,7 +17,7 @@ describe('WarframeCompanion', () => { t1: '9C5D42', t2: '9C5D42', t3: '413E3B', - en: 'F6DC13', + en: '0', }, attcol: { t0: 'B0BDB8', @@ -62,7 +62,8 @@ describe('WarframeCompanion', () => { emissive: [], energy: [ { - hex: 'F6DC13', + hex: '0', + isTransparent: true, matches: [], }, ],