blend-mode
a collection of channel-level blend modes, à la photoshop (shamelessly lifted from here, via here)
install
$ npm i blend-mode
usage
var blend = // Blends two values, each between 0 and 255// eg. pixel channel values
example
var multiply = var layer1 = 255 128 250 255 60 ... var layer2 = 156 24 18 223 119 ...// Where both layers are Uint8ClampedArrays acquired with// canvas.getContext('2d').getImageData(0, 0, w, h).data var blended = // Where blended is likely a Uint8ClampedArray acquired with// canvas.getContext('2d').createImageData(0, 0, w, h).data var total = Mathfor var i = 0; i < total; i += 4 blendedi = blendedi + 1 = blendedi + 2 = // don’t blend alpha channels blendedi + 3 = layer1i + 3
page weight (browserified)
you should really only require the blend-mode/s you actually need, but if you must have the kitchen sink, it will cost you:
compression | size |
---|---|
blend-mode.js | 3.89 kB |
blend-mode.min.js | 2.76 kB |
blend-mode.min.js.gz | 832 B |
license
let’s just say MIT and hope for the best?