Socket
Book a DemoInstallSign in
Socket

pixel-stack

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pixel-stack

Interface to composite RGB/RGBA buffers

npmnpm
Version
0.1.0
Version published
Weekly downloads
5
66.67%
Maintainers
1
Weekly downloads
 
Created
Source

pixel-stack

Interface to composite RGB/RGBA buffers together into larger buffers representing images.

How to use

var PixelStack = require('pixel-stack');
var stack = new PixelStack;
stack.fill([0,0,0]);
stack.push([255,255,255,255,255,255], 0, 0, 2, 1);
stack.push([255,255,255,255,255,255], 0, 1, 2, 1);
stack.buffer();

API

PixelStack(Number width, Number height, String type)

  • type can be 'rgb' or 'rgba'. Defaults to rgb.

PixelStack#push(Buffer data, Number w, Number h, Number x, Number y)

  • Inserts the data pixel buffer at the coordinates x,y
  • data can be any Array-like datastructure (Buffer, ArrayBuffer).
  • Returns the PixelStack instance.

PixelStack#fill(Buffer data)

  • Sets the given data pixel buffer as background color.
  • If not called, it'll default to filling with black (0,0,0) upon the first call to push or buffer.
  • Returns the PixelStack instance.

PixelStack#width()

  • Returns the width of the stack. Useful when not specified in the constructor and calculated dynamically.

PixelStack#height()

  • Returns the height of the stack. Useful when not specified in the constructor and calculated dynamically.

PixelStack#buffer()

  • Returns the calculated pixel Buffer.

PixelStack#destroy()

  • Cleans the internal buffer.

Credits

Inspired by the FixedJpegStack and DynamicJpegStack interfaces of the node-jpeg project by @pkrumins.

Authors

License

MIT – Copyright (c) 2014 Automattic, Inc.

FAQs

Package last updated on 04 Oct 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts