demos/Collage/fabric.js
function(callback) {
      var el = fabric.document.createElement('canvas');
      if (!el.getContext && typeof G_vmlCanvasManager != 'undefined') {
        G_vmlCanvasManager.initElement(el);
      }

      el.width = this.getBoundingRectWidth();
      el.height = this.getBoundingRectHeight();

      fabric.util.wrapElement(el, 'div');

      var canvas = new fabric.Canvas(el);
      canvas.backgroundColor = 'transparent';
      canvas.renderAll();

      if (this.constructor.async) {
        this.clone(proceed);
      }
      else {
        proceed(this.clone());
      }

      function proceed(clone) {
        clone.left = el.width / 2;
        clone.top = el.height / 2;

        clone.setActive(false);

        canvas.add(clone);
        var data = canvas.toDataURL('png');

        canvas.dispose();
        canvas = clone = null;

        callback && callback(data);
      }
    }
function(callback) {
      var el = fabric.document.createElement('canvas');
      if (!el.getContext && typeof G_vmlCanvasManager != 'undefined') {
        G_vmlCanvasManager.initElement(el);
      }

      el.width = this.getBoundingRectWidth();
      el.height = this.getBoundingRectHeight();

      fabric.util.wrapElement(el, 'div');

      var canvas = new fabric.Canvas(el);
      canvas.backgroundColor = 'transparent';
      canvas.renderAll();

      if (this.constructor.async) {
        this.clone(proceed);
      }
      else {
        proceed(this.clone());
      }

      function proceed(clone) {
        clone.left = el.width / 2;
        clone.top = el.height / 2;

        clone.setActive(false);

        canvas.add(clone);
        var data = canvas.toDataURL('png');

        canvas.dispose();
        canvas = clone = null;

        callback && callback(data);
      }
    }
function ( callback ) { var el = fabric . document . createElement ( 'canvas' ) ; if ( ! el . getContext && typeof G_vmlCanvasManager != 'undefined' ) { G_vmlCanvasManager . initElement ( el ) ; } el . width = this . getBoundingRectWidth ( ) ; el . height = this . getBoundingRectHeight ( ) ; fabric . util . wrapElement ( el , 'div' ) ; var canvas = new fabric . Canvas ( el ) ; canvas . backgroundColor = 'transparent' ; canvas . renderAll ( ) ; if ( this . constructor . async ) { this . clone ( proceed ) ; } else { proceed ( this . clone ( ) ) ; } function proceed ( clone ) { clone . left = el . width / 2 ; clone . top = el . height / 2 ; clone . setActive ( false ) ; canvas . add ( clone ) ; var data = canvas . toDataURL ( 'png' ) ; canvas . dispose ( ) ; canvas = clone = null ; callback && callback ( data ) ; } }
Converts an object into a data-url-like string
@method toDataURL
@return {String} string of data
Converts an object into a data - url - like string