Skip to content

Instantly share code, notes, and snippets.

View vorlovsky's full-sized avatar

Vyacheslav Orlovsky vorlovsky

View GitHub Profile
// width - image width
// height - image height
// input - two-dimentional array of RGBA pixels of original image
// output - two-dimentional array of RGBA pixels of processed image
// Both are initialized with the same image
// channel - R, G, or B channel to copy (shifted) in output image
// copyChannelPoint(x, y) - pseudopoint, specifying where to place (top left corener) shifted channel data from on output image
// copyPixelsData - pseudostrust, specifying areas of input image to be copied (shifted) to output:
Caman.Blender.register("darkerColor", function (rgbaLayer, rgbaParent) {
var LUMINANCE_WEIGHTING = [0.299, 0.587, 0.114];
return (CanvasHelpers.intensity(rgbaLayer, LUMINANCE_WEIGHTING) < CanvasHelpers.intensity(rgbaParent, LUMINANCE_WEIGHTING))
? CanvasHelpers.blend(rgbaParent, rgbaLayer)
: CanvasHelpers.blend(rgbaLayer, rgbaParent);
});
static intensity(rgba, luminanceWeighting)
{