diff --git a/.gitignore b/.gitignore index e192558..e092c0d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -test/* \ No newline at end of file +test/* +.DS_STORE +package-lock.json \ No newline at end of file diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..b08927e --- /dev/null +++ b/.npmignore @@ -0,0 +1,4 @@ +test/* +.git/* +.DS_STORE +package-lock.json \ No newline at end of file diff --git a/Aseprite.js b/Aseprite.js index fdc2d96..5e07319 100644 --- a/Aseprite.js +++ b/Aseprite.js @@ -11,6 +11,7 @@ class Aseprite { this.width; this.height; this.colorDepth; + this.paletteIndex; this.numColors; this.pixelRatio; this.name = name; @@ -100,7 +101,9 @@ class Aseprite { this.width = this.readNextWord(); this.height = this.readNextWord(); this.colorDepth = this.readNextWord(); - this.skipBytes(18); + this.skipBytes(14); + this.paletteIndex = this.readNextByte(); + this.skipBytes(3); this.numColors = this.readNextWord(); const pixW = this.readNextByte(); const pixH = this.readNextByte(); @@ -212,10 +215,14 @@ class Aseprite { name: name !== undefined ? name : "none" }); } - return { paletteSize, + let palette = { + paletteSize, firstColor, lastColor: secondColor, - colors }; + colors + } + this.colorDepth === 8 ? palette.index = this.paletteIndex : ''; + return palette; } readLayerChunk() { const flags = this.readNextWord(); diff --git a/README.md b/README.md index 1c40587..8cba511 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,7 @@ aseFile.parse(); | width | integer | width (in pixels) | | height | integer | height (in pixels) | | colorDepth | integer | color depth (in bits per pixel) | +| paletteIndex | integer | position of the indexed color based on the palette | | numColors | integer | number of colors | | pixelRatio | string | width:height | | name | string | name of the file | @@ -171,6 +172,7 @@ aseFile.parse(); | firstColor | integer | index of the first color | | lastColor | integer | index of the last color | | colors | array of [color](#color-object) objects | colors | +| index? | integer | position of the indexed color based on the palette | ## Cel Object | Field | Type | Description | diff --git a/package.json b/package.json index ffef661..58cf180 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ase-parser", - "version": "0.0.10", + "version": "0.0.12", "description": "Parser for Aseprite files", "main": "Aseprite.js", "typings": "./typings/Aseprite.d.ts", diff --git a/typings/Aseprite.d.ts b/typings/Aseprite.d.ts index f4b2c2f..28bc3fc 100644 --- a/typings/Aseprite.d.ts +++ b/typings/Aseprite.d.ts @@ -3,6 +3,12 @@ declare class Aseprite { layers: Array; tags: Array; palette: Aseprite.Palette; + colorProfile: Aseprite.ColorProfile; + name: string; + paletteIndex: number; + colorDepth: number; + pixelRatio: string; + numColors: number; fileSize: number; width: number; height: number; @@ -26,6 +32,7 @@ declare namespace Aseprite { firstColor: number; lastColor: number; colors: Array; + index?: number; } export interface Color { red: number; @@ -65,4 +72,10 @@ declare namespace Aseprite { numChunks: number; cels: Array; } + export interface ColorProfile { + type: string; + flag: number; + fGamma: number; + icc?: Buffer; + } } \ No newline at end of file