doom-patch-to-image-bitmap
v1.0.0
Published
Converts DOOM patch into ImageBitmap instance.
Downloads
14
Readme
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);
});