我正在使用具有多个图层的 camanjs 操作图像,如果我在任何子图层之外执行命令,则更改颜色通道有效,但是当我尝试在图层中使用 .channels 时,出现 JS 错误“通道不是函数” .
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();
});