Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

premultiplied-rgba

mattdesl104MIT1.0.1

standalone function to premultiply RGB by alpha channel

premultily, premultiplied, alpha, rgb, rgba, channel, channels

readme

premultiplied-rgba

frozen

Standalone function to premultiply RGB by alpha channel.

var premult = require('premultiplied-rgba')

premult([1, 1, 1, 0.5]) 

//=> returns new array [0.5, 0.5, 0.5, 0.5]

Usage

NPM

premultiply(rgba[, out])

Takes a 4-component array assumed to be in the form [R, G, B, A] and returns a new array with the RGB channels multiplied by the alpha channel.

The out param allows you to re-use an array rather than creating a new one. So you can premultiply an array in-place like so:

premultiply(rgba, rgba)

The out param will ignore numbers, so you can do array operations:

var premultiplied = colors.map(premultiply)

License

MIT, see LICENSE.md for details.