CamanJS this.channels throws an exception ("is no function"), but works outside of layers

123 Views Asked by At

I'm manipulating an image with camanjs with multiple layers, changing the color channels works if I execute the command outside of any sublayers, but when I try to use .channels in a layer I get a JS error "channels is not a function".

    loadImage(basetop, 'stack/yoko.jpg', w, h).done(function(){
            //Step 2: render filtered images
            var imgData=ctx.getImageData(0,0,basetop.width,basetop.height);
            basetop.getContext('2d').putImageData(imgData,0,0);
            Caman('#topFilterImage', function () {

                 //green layer
                 this.newLayer(function () {
                    // Change the blending mode
                    this.setBlendingMode("multiply");
                    this.copyParent();
                    this.channels({
                        red: -100,
                        green: 0,
                        blue: -100
                    });

                    this.saturation(-100);

                    this.colorize("#1684CA", 20);


                });
                //blue layer
                this.newLayer(function () {
                    // Change the blending mode
                    this.setBlendingMode("multiply");
                    this.copyParent();

                    this.channels({
                        red: -100,
                        green: -100,
                        blue: 0
                    });
                    this.saturation(-100);
                    this.colorize("#000080", 20);
                });

                 //red layer
                 this.newLayer(function () {
                    // Change the blending mode
                    this.setBlendingMode("multiply");
                    this.copyParent();
                    this.channels({
                        red: 0,
                        green: -100,
                        blue: -100
                    });
                    this.saturation(-100);
                    this.colorize("#ff0000", 20);

                });


                 this.render();

                });
0

There are 0 best solutions below