From 69442605b5aa592deb9a419f574226cf57a5e937 Mon Sep 17 00:00:00 2001 From: Ronin <6971304+TheCyberRonin@users.noreply.github.com> Date: Tue, 29 Nov 2022 11:27:48 -0500 Subject: [PATCH 1/6] feat: Add badges to README --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index abee0e4..0a1f7b0 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ +[![npm](https://img.shields.io/npm/v/ase-parser.svg)](https://www.npmjs.com/package/ase-parser) +[![npm](https://img.shields.io/npm/dt/ase-parser.svg?maxAge=3600)](https://www.npmjs.com/package/ase-parser) +[![install size](https://packagephobia.now.sh/badge?p=ase-parser)](https://packagephobia.now.sh/result?p=ase-parser) + # ase-parser Parse Aseprite files with Node.js, no external dependencies. From 5be553cd9e7e29b4badb56d279489580da934b77 Mon Sep 17 00:00:00 2001 From: CyberRonin Date: Sat, 3 Dec 2022 21:33:02 -0500 Subject: [PATCH 2/6] chore: Remove old `action` file --- main.yml | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 main.yml diff --git a/main.yml b/main.yml deleted file mode 100644 index e334b61..0000000 --- a/main.yml +++ /dev/null @@ -1,23 +0,0 @@ -# This is a basic workflow to help you get started with Actions - -name: CI - -# Controls when the action will run. -on: - release: - types: [published] - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - publish-npm: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: 12 - registry-url: https://registry.npmjs.org/ - - run: npm ci - - run: npm publish - env: - NODE_AUTH_TOKEN: ${{secrets.npm_token}} From df3dc95c31d3ea82f46473921015df868d60491a Mon Sep 17 00:00:00 2001 From: CyberRonin Date: Sun, 4 Dec 2022 10:59:46 -0500 Subject: [PATCH 3/6] docs: Add `gitflow.md` to explain organization --- docs/gitflow.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 docs/gitflow.md diff --git a/docs/gitflow.md b/docs/gitflow.md new file mode 100644 index 0000000..124c873 --- /dev/null +++ b/docs/gitflow.md @@ -0,0 +1,17 @@ +# Gitflow + +We'll be using the gitflow organization for the repo. I'll describe a TLDR version, but provide links to documents that explain it in further detail. + +### Organization + +The branches listed below will be used for the project. + + * `master` - Contains "production ready" code. i.e. The code that gets pushed to NPM. + * `develop` - Contains code that's currently in progress. This is the branch that should be targeted for PRs. + * `feature/*` - Contains a `feature`. This should be the current work for a single feature/addition to the codebase. It should have a sensible name. Let's say I want to comment all of the code, the feature branch name would be something like `feature/comment-js-files`. + * `release` - This is branched from `develop` when a release is ready and holds the code for a release. It will be used to test to make sure there are no bugs before it gets pushed to `master`. + * `hotfix` - If there is a bug in `master`, a hotfix branch is created with the fix to be merged DIRECTLY into master and then will be merged back into `develop` so that the fix is present in future code. + +### Resources + * [GitKraken](https://www.gitkraken.com/learn/git/git-flow) + * [Atlassian](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow) From 0fa1f1c197b493dd2f13748828286e72ba1ff7cf Mon Sep 17 00:00:00 2001 From: Ronin <6971304+TheCyberRonin@users.noreply.github.com> Date: Sun, 8 Oct 2023 20:28:57 -0400 Subject: [PATCH 4/6] feat: Translate layer flags into a map --- Aseprite.js | 40 +++++++++++++++++++++++++++++++++++++++- typings/Aseprite.d.ts | 11 ++++++++++- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/Aseprite.js b/Aseprite.js index f091099..c4f40a5 100644 --- a/Aseprite.js +++ b/Aseprite.js @@ -23,6 +23,23 @@ class Aseprite { this.tilesets = []; } + //#region Static Constants + + /** + * Map of the possible flag values for a Layer + */ + static LAYER_FLAG_MAP = { + visible: 0b1, + editable: 0b10, + lockMovement: 0b100, + background: 0b1000, + preferLinkedCels: 0b10000, + collapsedGroup: 0b100000, + reference: 0b1000000 + }; + + //#endregion Static Constants + /** * Reads the next byte (8-bit unsigned) value in the buffer * @@ -212,6 +229,27 @@ class Aseprite { this._offset += numBytes; } + /** + * Translates the listed flags for a layer into true/false values + * dictating whether or not that flag is "on"(true) or "off"(false) + * + * @private + * @param {object} flagMap Object of flags and their binary value + * @param {number} flagValue Value of the layer flags + * @returns {object} Map of the flags and if they are true or false + */ + #translateFlags(flagValue) { + // Create an object to put the flags and their "toggle" (true/false) + const translatedFlagMap = {}; + // Iterate through the flags and their binary value, use bitwise op + // to see if the flag is present in the "layer flags" and add the + // flag to the map with the accompanying "toggle" + for( const flag in Aseprite.LAYER_FLAG_MAP) { + translatedFlagMap[flag] = (flagValue & Aseprite.LAYER_FLAG_MAP[flag]) == Aseprite.LAYER_FLAG_MAP[flag]; + } + return translatedFlagMap; + } + /** * Reads the 128-byte header of an Aseprite file and stores the information * @@ -501,7 +539,7 @@ class Aseprite { */ readLayerChunk() { const layer = {} - layer.flags = this.readNextWord(); + layer.flags = this.#translateFlags(this.readNextWord()); layer.type = this.readNextWord(); layer.layerChildLevel = this.readNextWord(); this.skipBytes(4); diff --git a/typings/Aseprite.d.ts b/typings/Aseprite.d.ts index 3bf48f6..318abd9 100644 --- a/typings/Aseprite.d.ts +++ b/typings/Aseprite.d.ts @@ -83,7 +83,7 @@ declare namespace Aseprite { color: string; } export interface Layer { - flags: number; + flags: Aseprite.LayerFlags; type: number; layerChildLevel: number; blendMode: number; @@ -125,4 +125,13 @@ declare namespace Aseprite { fGamma: number; icc?: Buffer; } + export interface LayerFlags { + visible: boolean; + editable: boolean; + lockMovement: boolean; + background: boolean; + preferLinkedCels: boolean; + collapsedGroup: boolean; + reference: boolean; + } } \ No newline at end of file From f65c0f1491453b4edb695c8b8c810926596e462a Mon Sep 17 00:00:00 2001 From: Ronin <6971304+TheCyberRonin@users.noreply.github.com> Date: Sun, 8 Oct 2023 20:30:40 -0400 Subject: [PATCH 5/6] chore: Update README and add newline --- README.md | 15 ++++++++++++++- typings/Aseprite.d.ts | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7e256dd..a049b4b 100644 --- a/README.md +++ b/README.md @@ -155,7 +155,7 @@ aseFile.parse(); ## Layer Object | Field | Type | Description | |-----------------|---------|-------------------------------| -| flags | integer | flags for the layer | +| flags | [layer flags](#layer-flags-object) | flags for the layer translated into a map | | type | integer | type | | layerChildLevel | integer | layer child level | | opacity | integer | opacity (0-255) | @@ -271,6 +271,19 @@ aseFile.parse(); | x | integer | X position of the pivot | | y | integer | Y position of the pivot | +## Layer Flags Object + +This object is a utility object that will have ***ALL*** fields present. If a field is "on" it will be `true`, if the field is "off" it will be `false`. + +| Field | Description | +|-------|---------| +| visible | Whether or not the layer is visible | +| editable | Whether or not the layer is editable | +| lockMovement | Whether or not the layer is a background layer | +| preferLinkedCels | Whether or not the layer prefers linked cels | +| collapsedGroup | Whether or not the layer group should be displayed collapsed | +| reference | Whether or not the layer is a reference layer | + # Further Info If you would like to read up on the Aseprite file spec: [Spec](https://github.com/aseprite/aseprite/blob/master/docs/ase-file-specs.md) \ No newline at end of file diff --git a/typings/Aseprite.d.ts b/typings/Aseprite.d.ts index 318abd9..eb62552 100644 --- a/typings/Aseprite.d.ts +++ b/typings/Aseprite.d.ts @@ -134,4 +134,4 @@ declare namespace Aseprite { collapsedGroup: boolean; reference: boolean; } -} \ No newline at end of file +} From e5b6065534b5a67e795b997492b21c0892ee4ca1 Mon Sep 17 00:00:00 2001 From: Ronin <6971304+TheCyberRonin@users.noreply.github.com> Date: Sun, 8 Oct 2023 20:32:21 -0400 Subject: [PATCH 6/6] chore: Bump version for release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3878c15..a6b82eb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ase-parser", - "version": "0.0.17", + "version": "0.0.18", "description": "Parser for Aseprite files", "main": "Aseprite.js", "typings": "./typings/Aseprite.d.ts",