使用Camanjs

时间:2015-07-28 13:05:33

标签: camanjs

在CamanJS上有一个添加一些效果和新图层的例子:

Caman("#image", function () {
  // We can call any filter before the layer
  this.exposure(-10);

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

    // Change the opacity of this layer
    this.opacity(80);

    // Now we can *either* fill this layer with a
    // solid color...
    this.fillColor('#6899ba');

    // ... or we can copy the contents of the parent
    // layer to this one.
    this.copyParent();

    // Now, we can call any filter function though the
    // filter object.
    this.filter.brightness(10);
    this.filter.contrast(20);
  });

  // And we can call more filters after the layer
  this.clip(10);
  this.render();
});

一切正常。我试图通过再次使用其他参数调用此代码来添加第二层图像我之前添加了图层,但是比第一层消失了。

在网站上还有如何添加单一效果的示例。它们很棒,但它们一次只能调用一个过滤器。

我想要实现的是,根据用户设置,添加例如一个图层,两个图层,或应用不透明度和新图层。

而且我希望它每次都能在基本图像上工作,而不是上次过滤时的图像效果。

那么,根据使用CamanJS的用户设置,使用多个滤镜和图层更改基本图像的正确方法是什么?

1 个答案:

答案 0 :(得分:1)

你现在可能已经想到了这一点,但你可以打电话给#34; this.revert(false)"渲染后确保您正在编辑基本图像。

您可以通过调用流程中的所有效果并使用if / then语句来确定用户输入来添加多个效果。例如=

单击按钮时,x + = 1 if(x%2 === 0){this.yourfilter();}

我刚刚开始。

相关问题