1

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

4

1 回答 1

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
})
于 2017-02-25T15:50:28.937 回答