vendor/kinetic-v5.1.0.js
function(config) {
            config = config || {};

            var mimeType = config.mimeType || null,
                quality = config.quality || null,
                x = config.x || 0,
                y = config.y || 0,
                canvas = new Kinetic.SceneCanvas({
                    width: config.width || this.getWidth(),
                    height: config.height || this.getHeight(),
                    pixelRatio: 1
                }),
                _context = canvas.getContext()._context,
                layers = this.children;

            if(x || y) {
                _context.translate(-1 * x, -1 * y);
            }

            function drawLayer(n) {
                var layer = layers[n],
                    layerUrl = layer.toDataURL(),
                    imageObj = new Kinetic.window.Image();

                imageObj.onload = function() {
                    _context.drawImage(imageObj, 0, 0);

                    if(n < layers.length - 1) {
                        drawLayer(n + 1);
                    }
                    else {
                        config.callback(canvas.toDataURL(mimeType, quality));
                    }
                };
                imageObj.src = layerUrl;
            }
            drawLayer(0);
        }
function(config) {
            config = config || {};

            var mimeType = config.mimeType || null,
                quality = config.quality || null,
                x = config.x || 0,
                y = config.y || 0,
                canvas = new Kinetic.SceneCanvas({
                    width: config.width || this.getWidth(),
                    height: config.height || this.getHeight(),
                    pixelRatio: 1
                }),
                _context = canvas.getContext()._context,
                layers = this.children;

            if(x || y) {
                _context.translate(-1 * x, -1 * y);
            }

            function drawLayer(n) {
                var layer = layers[n],
                    layerUrl = layer.toDataURL(),
                    imageObj = new Kinetic.window.Image();

                imageObj.onload = function() {
                    _context.drawImage(imageObj, 0, 0);

                    if(n < layers.length - 1) {
                        drawLayer(n + 1);
                    }
                    else {
                        config.callback(canvas.toDataURL(mimeType, quality));
                    }
                };
                imageObj.src = layerUrl;
            }
            drawLayer(0);
        }
function ( config ) { config = config || { } ; var mimeType = config . mimeType || null , quality = config . quality || null , x = config . x || 0 , y = config . y || 0 , canvas = new Kinetic . SceneCanvas ( { width : config . width || this . getWidth ( ) , height : config . height || this . getHeight ( ) , pixelRatio : 1 } ) , _context = canvas . getContext ( ) . _context , layers = this . children ; if ( x || y ) { _context . translate ( - 1 * x , - 1 * y ) ; } function drawLayer ( n ) { var layer = layers [ n ] , layerUrl = layer . toDataURL ( ) , imageObj = new Kinetic . window . Image ( ) ; imageObj . onload = function ( ) { _context . drawImage ( imageObj , 0 , 0 ) ; if ( n < layers . length - 1 ) { drawLayer ( n + 1 ) ; } else { config . callback ( canvas . toDataURL ( mimeType , quality ) ) ; } } ; imageObj . src = layerUrl ; } drawLayer ( 0 ) ; }
Creates a composite data URL and requires a callback because the composite is generated asynchronously.
@method
@memberof Kinetic.Stage.prototype
@param {Object} config
@param {Function} config.callback function executed when the composite has completed
@param {String} [config.mimeType] can be "image/png" or "image/jpeg".
"image/png" is the default
@param {Number} [config.x] x position of canvas section
@param {Number} [config.y] y position of canvas section
@param {Number} [config.width] width of canvas section
@param {Number} [config.height] height of canvas section
@param {Number} [config.quality] jpeg quality.  If using an "image/jpeg" mimeType,
you can specify the quality from 0 to 1, where 0 is very poor quality and 1
is very high quality
Creates a composite data URL and requires a callback because the composite is generated asynchronously .