2017-02-22 117 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