javascript - Pixastic ColorAdjust 类型错误未定义

标签 javascript jquery html pixastic

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

相关文章:

javascript - 我如何才能等到 IndexedDB 实例关闭?

html - css 背景属性在 chrome 和 firefox 中不起作用

javascript - 如何为react-router路由器设置基本名称

javascript - 如何为 createReadStream 分配缓冲区

javascript - 如何从 Firebase 存储获取 DownloadURL

javascript - HTML 多重选择值作为 GET 变量中的逗号分隔字符串

jquery - 淡入 jquery [不工作]

jquery - IE6 - jQuery UI 对话框 - 通过覆盖显示的元素

javascript - 具有固定标题和滚动表体的表不允许 tbody 滚动

HTML5 : Why not use my own arbitrary tag names?