2017-02-22 207 views
1

我真的希望有人能夠幫助...我有雙倍和三倍和四重檢查Pixastic庫加載。Pixastic ColorAdjust類型錯誤未定義

這裏是我的HTML代碼:

<head>標籤:

<script src="pathto.../pixastic.js"></script> 
<script src="pathto.../pixastic.effects.js"></script> 
<script src="pathto.../pixastic.worker.js"></script> 

<body>標籤:

<div id="pattern-div" class=""> 
<div id="preview-background-print"><img id="preview-image" src="/image.png"/></div> 
</div> 

這裏是jQuery的。我忽略了計算RGB偏移量的公式,因爲它們似乎不相關。但是讓我知道他們是否。 :)

$('#preview-image').pixastic('coloradjust',{ 
    red : pixadjustR, 
    green : pixadjustG, 
    blue : pixadjustB 
}); 

這是我得到的錯誤:

TypeError: $('#preview-image').pixastic is not a function. (In '$('#preview-image').pixastic('coloradjust',{ 
     red : pixadjustR, 
     green : pixadjustG, 
     blue : pixadjustB 
    })', '$('#preview-image').pixastic' is undefined)` 

(我自己也嘗試Pixastic.process(document.getElementById("preview-image"), "coloradjust"...並得到Pixastic.process is not a function

回答

1

你包括pixastic jquery plugin

?如果你想在沒有jQuery插件的情況下這樣做,這與他們如何在demo

function pixastic(img, method, options){ 
    // Copy image to canvas 
    var canvas = document.createElement('canvas'); 
    canvas.width = img.width; 
    canvas.height = img.height; 
    var ctx = canvas.getContext("2d"); 
    ctx.drawImage(img, 0, 0); 
    // Create Pixastic object and execute filter. 
    // The second parameter is the path to the folder containing the worker script 
    var P = new Pixastic(ctx); 
    P[method](options).done(function(){ 
     // Copy the data back to the image as dataURI 
     img.src = canvas.toDataURL(); 
    }); 
} 
pixastic($('img')[0], "coloradjust", { 
    red : pixadjustR, 
    green : pixadjustG, 
    blue : pixadjustB 
}) 
+0

謝謝你的幫助!我確實包含了它。我最終解決了我的問題,但我討厭說我忘記了我的所作所爲。當你嘗試1000件事,其中一件起作用時,這往往會發生(無論如何)。 – NYCjbd