1.0.0 • Published 8 years ago

mask-repack v1.0.0

Weekly downloads
8
License
MIT
Repository
github
Last release
8 years ago

mask-repack

stable

Takes a pair of color and alpha images and combines them into a single transparent image. Works both in-browser and node.

Usage

NPM

combined = repack(color, alpha)

Takes color and alpha, two images encoded as ndarrays, and returns a single combined ndarray image.

For example, you can combine this with mask-unpack in a preprocessing step to get transparent images encoded with JPG instead of PNG, potentially saving on page weight for certain images.

const Texture = require('gl-texture2d')
const repack = require('mask-repack')
const load = require('get-pixels')

load('image-color.jpg', function (err, color) {
  load('image-alpha.jpg', function (err, alpha) {
    const data = repack(color, alpha)
    const texture = Texture(gl, data)
  })
})

See Also

License

MIT, see LICENSE.md for details.