@
wensonsmith 这个是canvas生成模糊image的方法:
var CanvasImage = function(ele,img) {
this.element = ele;
this.image = img;
this.element.width = this.image.width;
this.element.height = this.image.height;
this.context = this.element.getContext("2d");
this.context.drawImage(this.image,0,0)
};
CanvasImage.prototype.blur = function(i) {
this.context.globalAlpha = 0.5;
for (var y = -i; y <= i; y += 2) {
for (var x = -i; x <= i; x += 2) {
this.context.drawImage(this.element, x, y)
if (x >= 0 && y >= 0) {
this.context.drawImage(this.element, -(x-1), -(y-1))
}
}
}
this.context.globalAlpha = 1
};
其实就是双层图片模拟的,上层是canvas,下层是原来image