Pixastic ColorAdjust Тип ошибки Не определено

Я действительно надеюсь, что кто-нибудь сможет помочь... Я проверил дважды, три и четыре раза, что библиотеки Pixastic загружаются.

Вот мой 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?

Если вы хотите сделать это без плагина jquery, это похоже на то, как они это делают в демо:

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
})
Другие вопросы по тегам