1.0.0 • Published 2 years ago

doom-patch-to-image-bitmap v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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);
});
1.0.0

2 years ago