@@ -529,6 +529,46 @@ var CanvasRenderer = new Class({
529529 }
530530 } ,
531531
532+ /**
533+ * Takes a snapshot of the given area of the given canvas.
534+ *
535+ * Unlike the other snapshot methods, this one is processed immediately and doesn't wait for the next render.
536+ *
537+ * Snapshots work by creating an Image object from the canvas data, this is a blocking process, which gets
538+ * more expensive the larger the canvas size gets, so please be careful how you employ this in your game.
539+ *
540+ * @method Phaser.Renderer.Canvas.CanvasRenderer#snapshotCanvas
541+ * @since 3.19.0
542+ *
543+ * @param {HTMLCanvasElement } canvas - The canvas to grab from.
544+ * @param {Phaser.Types.Renderer.Snapshot.SnapshotCallback } callback - The Function to invoke after the snapshot image is created.
545+ * @param {boolean } [getPixel=false] - Grab a single pixel as a Color object, or an area as an Image object?
546+ * @param {integer } [x=0] - The x coordinate to grab from.
547+ * @param {integer } [y=0] - The y coordinate to grab from.
548+ * @param {integer } [width=canvas.width] - The width of the area to grab.
549+ * @param {integer } [height=canvas.height] - The height of the area to grab.
550+ * @param {string } [type='image/png'] - The format of the image to create, usually `image/png` or `image/jpeg`.
551+ * @param {number } [encoderOptions=0.92] - The image quality, between 0 and 1. Used for image formats with lossy compression, such as `image/jpeg`.
552+ *
553+ * @return {this } This Canvas Renderer.
554+ */
555+ snapshotCanvas : function ( canvas , callback , getPixel , x , y , width , height , type , encoderOptions )
556+ {
557+ if ( getPixel === undefined ) { getPixel = false ; }
558+
559+ this . snapshotArea ( x , y , width , height , callback , type , encoderOptions ) ;
560+
561+ var state = this . snapshotState ;
562+
563+ state . getPixel = getPixel ;
564+
565+ CanvasSnapshot ( this . canvas , state ) ;
566+
567+ state . callback = null ;
568+
569+ return this ;
570+ } ,
571+
532572 /**
533573 * Schedules a snapshot of the entire game viewport to be taken after the current frame is rendered.
534574 *
0 commit comments