赞 | 8 |
VIP | 0 |
好人卡 | 0 |
积分 | 28 |
经验 | 0 |
最后登录 | 2023-10-19 |
在线时间 | 130 小时 |
Lv3.寻梦者
- 梦石
- 0
- 星屑
- 2754
- 在线时间
- 130 小时
- 注册时间
- 2011-8-7
- 帖子
- 70
|
SceneManager.snapForBackground = function() {
this._backgroundBitmap = this.snap();
this._backgroundBitmap.blur();
};
这里的: this._backgroundBitmap.blur();
这个对应的是一个bitmap。。
所以对应下面这里。
Bitmap.prototype.blur = function() {
for (var i = 0; i < 2; i++) {
var w = this.width;
var h = this.height;
var canvas = this._canvas;
var context = this._context;
var tempCanvas = document.createElement('canvas');
var tempContext = tempCanvas.getContext('2d');
tempCanvas.width = w + 2;
tempCanvas.height = h + 2;
tempContext.drawImage(canvas, 0, 0, w, h, 1, 1, w, h);
tempContext.drawImage(canvas, 0, 0, w, 1, 1, 0, w, 1);
tempContext.drawImage(canvas, 0, 0, 1, h, 0, 1, 1, h);
tempContext.drawImage(canvas, 0, h - 1, w, 1, 1, h + 1, w, 1);
tempContext.drawImage(canvas, w - 1, 0, 1, h, w + 1, 1, 1, h);
context.save();
context.fillStyle = 'black';
context.fillRect(0, 0, w, h);
context.globalCompositeOperation = 'lighter';
context.globalAlpha = 1 / 9;
for (var y = 0; y < 3; y++) {
for (var x = 0; x < 3; x++) {
context.drawImage(tempCanvas, x, y, w, h, 0, 0, w, h);
}
}
context.restore();
}
this._setDirty();
}; |
|