doom-patch-to-image-bitmap
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

doom-patch-to-image-bitmap

Converts DOOM patch into ImageBitmap instance that can be then rendered to canvas.

Installation

$ npm install --save doom-patch-to-image-bitmap

Usage

This NPM package provides single function called doomPatchToImageBitmap. The function takes [2D context] of an canvas, DOOM patch, DOOM colormap and DOOM palette provided by @rauli/wad library and returns an promise that will resolve into ImageBitmap instance if the given patch can be rendered with the given colormap and palette.

import { createObjectModel, readWad } from "@rauli/wad";
import { doomPatchToImageBitmap } from "doom-patch-to-image-bitmap";

const model = createObjectModel(readWad(...));
const context = document.querySelector("canvas").getContext("2d");

doomPatchToImageBitmap(
  context,
  model.sprites.PLAYB1,
  model.colormap[0],
  model.playpal[0]
).then((bitmap) => {
  context.drawImage(bitmap, 0, 0);
});

Readme

Keywords

Package Sidebar

Install

npm i doom-patch-to-image-bitmap

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

3.32 kB

Total Files

6

Last publish

Collaborators

  • rauli