genie-slp
SLP graphics file parser for Node.js
Last updated 3 years ago by goto-bus-stop .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install genie-slp 
SYNC missed versions from official npm registry.

genie-slp

Genie Engine .SLP graphic file reader in Node.js

NPM

Usage Example

let fs = require('fs')

// Load a Palette file using the `jascpal` module
let Palette = require('jascpal')
let mainPalette = Palette(fs.readFileSync('palette.pal'))

// Load an SLP file and render a frame
let SLP = require('genie-slp')
let slp = SLP(fs.readFileSync('my-file.slp'))
let frame = slp.renderFrame(0, mainPalette, { player: 7 })

// Render the returned ImageData object to a PNG file
let { PNG } = require('pngjs')
let png = new PNG({
  width: frame.width,
  height: frame.height
})
png.data = Buffer.from(frame.data.buffer)
png.pack().pipe(fs.createWriteStream('my-file.png'))

API

SLP(buffer: Buffer)

Creates an SLP graphic from a buffer.

SLP#renderFrame(frameIndex: number, palette: Palette, { player: number, drawOutline: boolean }): ImageData

Renders a frame to an [ r, g, b, a ] ImageData object.

Parameters

  • frameIndex - The SLP frame ID to render.
  • palette - A colour palette: an array of [ r, g, b ] colour arrays, probably from the jascpal module.
  • options - Optionally, an object with properties:
    • player - Player colour (1-8) to use for player-specific parts. Defaults to 1 (blue).
    • drawOutline - Whether to draw an outline (used when units are behind buildings, etc). Defaults to false.

In the browser, returns an ImageData object that can be drawn to a Canvas. In node, returns a plain object with the data as a Uint8ClampedArray, the width of the frame, and the height of the frame (like the ImageData API).

Related

  • jascpal - JASC Paint Shop Pro palette file parser--these are the palette files used by the Genie engine
  • genie-drs - Read and manipulate Genie Engine .DRS file archives

License

MIT

Current Tags

  • 1.1.0                                ...           latest (3 years ago)

7 Versions

  • 1.1.0                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
  • 0.7.4                                ...           5 years ago
  • 0.7.3                                ...           5 years ago
  • 0.7.2                                ...           5 years ago
  • 0.7.1                                ...           6 years ago
  • 0.7.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (3)
Dependents (2)

Copyright 2014 - 2017 © taobao.org |