lwim

0.1.3 • Public • Published

lwim

NPM version Build Status Dependency Status Coverage percentage

Light Weight Image Manipulation for NodeJS. It is forked from mono-bitmap

Installation

$ npm install --save lwim

Features

  • Creating bitmaps (1, 2 or 4 bytes per pixel, in big- or little-endian)
  • Changing the color depth
  • Reading 8-bit .bmp files
  • Saving .bmp files
  • Getting/setting pixels
  • Change the color of every pixel in a specific color
  • Drawing rectangles (horizontal gradient in greyscale possible)
  • Drawing circles/ellipses
  • Inverting the bitmap
  • Drawing a bitmap or a portion of it on a bitmap
  • Drawing text with a bitmap font

Example

"use strict";
 
var lwim = require("..");
 
// Create bitmap
var bitmap = lwim.bitmap(411, 305);
 
// Draw rectangle with border
bitmap.drawFilledRect(10, 10, 100, 50, 0x00, 0xff);
bitmap.drawEllipse(50, 100, 200, 100, 0x00, 0xff);
 
// Draw another bitmap with some source pixels in a specific color handled as transparent
var overlayBitmap = lwim.bitmap.fromFile("overlayBitmap.bmp");
bitmap.drawBitmap(overlayBitmap, 200, 0, overlayBitmap.palette.indexOf(0xff00ff/*magenta*/));
 
// Draw text
var  font = new lwim.Font("P:\\ath\\to\\Font.json");
font.setSize(20);
bitmap.drawText(font, "Hello World!", 10, 100);
 
// The raw pixel data can also be processed in a user-specific way
var data = bitmap.data;  // Return a Node.js Buffer

Documentation

The documentation can be generated from the source code by:

[jsdoc](http://usejsdoc.org/) index.js

License

MIT © taoyuan

Package Sidebar

Install

npm i lwim

Weekly Downloads

12

Version

0.1.3

License

MIT

Last publish

Collaborators

  • bitt