2018-02-09 13:46:04 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @function Phaser.Renderer.Snapshot.Canvas
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {HTMLCanvasElement} canvas - [description]
|
|
|
|
* @param {string} [type='image/png'] - [description]
|
|
|
|
* @param {float} [encoderOptions=0.92] - [description]
|
|
|
|
*
|
|
|
|
* @return {Image} [description]
|
|
|
|
*/
|
2018-01-07 13:27:07 +00:00
|
|
|
var CanvasSnapshot = function (canvas, type, encoderOptions)
|
2017-05-16 19:15:01 +00:00
|
|
|
{
|
2018-01-07 13:27:07 +00:00
|
|
|
if (type === undefined) { type = 'image/png'; }
|
|
|
|
if (encoderOptions === undefined) { encoderOptions = 0.92; }
|
|
|
|
|
|
|
|
var src = canvas.toDataURL(type, encoderOptions);
|
2017-07-04 12:10:26 +00:00
|
|
|
|
|
|
|
var image = new Image();
|
|
|
|
|
2017-05-16 19:15:01 +00:00
|
|
|
image.src = src;
|
2017-07-04 12:10:26 +00:00
|
|
|
|
2017-05-16 19:15:01 +00:00
|
|
|
return image;
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = CanvasSnapshot;
|