Skip to content

RauliL/doom-patch-to-image-bitmap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Converts DOOM patch into ImageBitmap instance

Topics

Resources

Stars

Watchers

Forks