@nrkn/act
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

act

Read and write Adobe Color Table files

npm install @nrkn/act

const { fromAct, toAct } = require( '@nrkn/act' )
import { fromAct, toAct } from '@nrkn/act'

fromAct

Reads an Adobe Color Table .ACT file from an ArrayLike (eg Buffer, Uint8Array, [1,2,3], etc ) and returns a Palette object

type Palette = {
  palette: [ number, number, number ][]
  transparent?: number
}

With no transparency:

const act = readFileSync( 'palette.act' )

const pal = fromAct( act )

// { palette: [ [ 0, 0, 0 ], [ 255, 255, 255 ] ] } 
console.log( pal )

With transparency:

const act = readFileSync( 'palette-with-transparency.act' )

const pal = fromAct( act )

// { palette: [ [ 0, 0, 0 ], [ 255, 255, 255 ] ], transparent: 1 } 
console.log( pal )

toAct

Takes a Palette (see above) and returns an Adobe Color Table .ACT file encoded as a Uint8ClampedArray

With no transparency:

const pal = { palette: [ [ 0, 0, 0 ], [ 255, 255, 255 ] ] }

const act = toAct( pal )

writeFileSync( 'palette.act', act )

With transparency:

const pal = { 
  palette: [ [ 0, 0, 0 ], [ 255, 255, 255 ] ],
  transparent: 1
}

const act = toAct( pal )

writeFileSync( 'palette-with-transparency.act', act )

license

MIT License

Copyright (c) 2022 Nik Coughlin

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Package Sidebar

Install

npm i @nrkn/act

Weekly Downloads

1

Version

0.1.1

License

MIT

Unpacked Size

19 kB

Total Files

30

Last publish

Collaborators

  • nrkn