【问题标题】:Create function for CamanJS Plugin为 CamanJS 插件创建函数
【发布时间】:2014-03-29 18:20:56
【问题描述】:

有没有机会创建一个我可以调用的函数?

如果我将以下几行放在文档就绪函数中,它会起作用:

Caman("25-02-2014_16-37-13.jpg", "#example-canvas", function () {
  this.brightness(brightness);
  this.render(function () {
    check = this.toBase64(); 
  });

但如果我这样做,我不能打电话。所以我尝试了这个:

function icancall()
{
  Caman("25-02-2014_16-37-13.jpg", "#example-canvas", function () {
  this.brightness(brightness);
  this.render(function () {
    check = this.toBase64();
  });
}

所以我想我可以用 icancall();但是什么也没发生。我究竟做错了什么? 我想要做的:单击按钮执行卡曼函数。

希望你能帮帮我!

【问题讨论】:

  • 把它放在一个函数中应该不会影响卡曼代码。您是否确认您正在使用您的功能 icancall 并且您的功能上的制表符间距是错误的。您需要在 Caman 下方缩进。

标签: javascript jquery function plugins camanjs


【解决方案1】:
            function resz(){

        Caman("25-02-2014_16-37-13.jpg", "#example-canvas", function  () {
            try {


                this.render(function () {
                    var image = this.toBase64();

                    xyz(image); // call that function where you pass filters 

                });
            } catch (e) { alert(e) }
        });

}

[通过此函数应用 CamanJS 过滤器]

 function xyz(image){

                var filters_k = $('#filters');

                filters_k.click(function (e) {

                    e.preventDefault();

                    var f = $(this);

                    if (f.is('.active')) {
                        // Apply filters only once
                        return false;
                    }

                    filters_k.removeClass('active');
                    f.addClass('active');
                    var effect = $.trim(f[0].id);
                    Caman(canvasID, img, function () {

                        if (effect in this) {

                            this.revert(false);
                            this[effect]();
                            this.render();

                        }

                    });
                });  
            }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-18
    • 1970-01-01
    • 1970-01-01
    • 2017-08-01
    相关资源
    最近更新 更多