Pixastic Blur不工作 - 变量问题? [英] Pixastic Blur not working - variable issue?

查看:121
本文介绍了Pixastic Blur不工作 - 变量问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我想试试 Pixastic blur fast method 来模糊图片。
他们在文档中提供的代码如下:

So I want to try the Pixastic blur fast method to blur an image. The code they supply in the documentation is the following:

var img = new Image();
img.onload = function() {
    Pixastic.process(img, "blurfast", {amount:0.5});
}
document.body.appendChild(img);
img.src = "myimage.jpg";

但是当我在我的页面上尝试这样的时候:

But when I try it on my page like this:

$(document).ready(function() {
    var myImg = new Image();
    myImg.onload = function() {
        Pixastic.process(myImg, "blurfast", {amount:0.5});
    }
    document.body.appendChild(myImg);
    myImg.src = "../img/theImage.jpg";
});

它什么都不做。

I也尝试这样称呼它,也没有任何结果:

I also tried to call it like this, also without any result:

var img = new Image();
$(".div img").load(function(){
    Pixastic.process(img, "blurfast", {amount:0.5});
});
document.body.appendChild(img);
img.src = "../img/theImage.jpg";

它甚至不会抛出错误!

我试图了解发生了什么:在 img 中,创建了一个新图像。一旦加载了 .div 中的图像,Pixastic就会触发并将模糊效果添加到新创建的图像中。现在,图像作为子图像应用并获得 src 属性。

I tried to understand what is happening: In img, a new image is created. As soon as the image in .div has loaded, Pixastic fires and adds the blur effect to the newly created image. Now, the image is applied as a child and gets a src attribute.

正如您可能注意到的那样,我有那里有一些逻辑错误,但我不明白这一点。我相信在上面的代码中, img 并不总是一样的。有时它是变量,有时它必须是来自 img -tag的实际图像。这是真的?或者你看到任何其他东西袭击你?为什么它不起作用?

As you probably notice, I have some logical errors in there, but I can't get this clear. I believe that in the above code, img is not always the same. Sometimes it's the variable, sometimes it has to be the actual image from the img-tag. Is this true? Or do you see any other thing that strikes you? Why is it not working?

推荐答案

好的,明白了!
由于某种原因,我需要通过jQuery方法调用它。喜欢:

Ok, got it! I need to call it through the jQuery method for some reason. Like:

$(".div img").pixastic("blurfast", {amount:0.5});

这篇关于Pixastic Blur不工作 - 变量问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆