Project1
标题:
MV中的截屏和模糊指令是什么?
[打印本页]
作者:
gaofei677
时间:
2016-2-2 23:43
标题:
MV中的截屏和模糊指令是什么?
本帖最后由 gaofei677 于 2016-2-2 23:50 编辑
我知道在VA中,截屏和模糊指令是
JAVASCRIPT 代码
复制
Graphics.
snap_to_bitmap
Graphics.
snap_to_bitmap
JAVASCRIPT 代码
复制
.
bitmap
.
blur
.
bitmap
.
blur
但是在MV中是什么呢?我在
http://miaowm5.github.io/RMMV-F1/
(F1帮助文档)
http://www.goodboydigital.com/pixijs/docs/classes/ImageLoader.html
(PIXI.JS帮助文档)
里面都没有找到,修大侠指导~谢谢~
作者:
汪汪
时间:
2016-2-3 07:17
//拍摄
SceneManager.snap = function() {
return Bitmap.snap(this._scene);
};
//拍摄 为了背景
SceneManager.snapForBackground = function() {
//背景图片 设置为 拍摄
this._backgroundBitmap = this.snap();
//背景图片 模糊
this._backgroundBitmap.blur();
};
//背景图片
SceneManager.backgroundBitmap = function() {
return this._backgroundBitmap;
};
复制代码
Bitmap.snap = function(stage) {
var width = Graphics.width;
var height = Graphics.height;
var bitmap = new Bitmap(width, height);
var context = bitmap._context;
var renderTexture = new PIXI.RenderTexture(width, height);
if (stage) {
renderTexture.render(stage);
stage.worldTransform.identity();
}
if (Graphics.isWebGL()) {
var gl = renderTexture.renderer.gl;
var webGLPixels = new Uint8Array(4 * width * height);
gl.bindFramebuffer(gl.FRAMEBUFFER, renderTexture.textureBuffer.frameBuffer);
gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, webGLPixels);
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
var canvasData = context.getImageData(0, 0, width, height);
canvasData.data.set(webGLPixels);
context.putImageData(canvasData, 0, 0);
} else {
context.drawImage(renderTexture.textureBuffer.canvas, 0, 0);
}
bitmap._setDirty();
return 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();
};
复制代码
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1