genie-slp
Genie Engine .SLP graphic file reader in Node.js
Usage Example
let fs = // Load a Palette file using the `jascpal` modulelet Palette = let mainPalette = // Load an SLP file and render a framelet SLP = let slp = let frame = slp // Render the returned ImageData object to a PNG filelet PNG = let png = width: framewidth height: frameheightpngdata = Bufferpng
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