我真的希望有人能够提供帮助......我有两倍,三倍和四倍检查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
等等。
答案 0 :(得分: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
})