Skip to content

Conversation

goto-bus-stop
Copy link
Member

This PR adds a basic SLP file encoder.

const SLPEncoder = require('genie-slp/lib/SLPEncoder')

const encoder = SLPEncoder({
  palette: somePalette,
  comment: 'optional comment', // up to 24 characters
  version: '1.00' // default '1.00', probably shouldn't touch this
})

encoder.addFrame(imageData) // object with `width`, `height`, `data` properties, like a DOM ImageData object
encoder.addFrame(imageData2)

const buffer = encoder.encode()

It doesn't support streaming, because the SLP file header contains pointers to the start of every frame. So, before writing the header at the start of the file, we need to have encoded every frame. One could create a stream from an SLPEncoder object by doing fromBuffer(encoder.encode()) with from2-buffer if they'd like.

TODO:

  • Support player colours
  • _EX commands
  • Outlines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant