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();
});
それは正常に動作します。以前にレイヤーを追加した画像に他のパラメーターを指定してこのコードを再度呼び出して、2 番目のレイヤーを追加しようとしましたが、最初のレイヤーが消えてしまいました。
Web サイトには、単一の効果を追加する方法の例もあります。それらは優れていますが、一度に 1 つのフィルターしか呼び出しません。
私が達成したいのは、ユーザー設定に基づいて、たとえば1つのレイヤー、2つのレイヤーを追加するか、不透明度と新しいレイヤーを適用することです。
また、最後のフィルタリングによる画像効果ではなく、ベース画像で毎回動作するようにしたいと思います。
では、CamanJS を使用してユーザー設定に応じて複数のフィルターとレイヤーでベース イメージを変更する適切な方法は何ですか?