2014-02-26 27 views
0

有沒有機會創建一個我可以調用的函數?爲CamanJS Plugin創建函數

如果我把下面的行它的工作文檔準備功能:

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()調用它;但沒有發生。我究竟做錯了什麼? 我想做什麼:按下按鈕執行Caman功能。

我希望你能幫助我!

+0

把它在函數內部不應該影響Caman代碼。你是否確認你的功能icancall 您的功能上的標籤間距也是錯誤的。你需要在卡曼下面縮進。 – bobbdelsol

回答

0
  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(); 

         } 

        }); 
       }); 
      }