gpt4 book ai didi

javascript - Pixastic ColorAdjust 类型错误未定义

转载 作者:太空宇宙 更新时间:2023-11-04 15:59:23 26 4
gpt4 key购买 nike

我真的希望有人能够提供帮助...我已经两次、三次和四次检查 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 等。

最佳答案

您是否包含 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
})

关于javascript - Pixastic ColorAdjust 类型错误未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42398708/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com