javascript - Capturing entire canvas as an image - Fabric JS -


i'm creating designer angular 2 using fabric js in user adds background image , overlays text, shapes etc.

at stage, want able replicate canvas (in modal checkout screen) user can have thumbnail preview of design: preferably image.

is there built in fabric function allow this? or plugin might better suited?

here need

var canvas  = new fabric.canvas('canvascontainer');  var rect = new fabric.rect({          left: 100,          top: 100,          fill:  "#ff0000",          stroke: "black",          width: 100,          height: 100,          strokewidth: 10,       });                canvas.add(rect);         canvas.renderall();  var converttoimage=function(){    canvas.deactivateall().renderall();      document.getelementbyid("ten").src=canvas.todataurl('png');   }  converttoimage();
<script src="https://rawgithub.com/kangax/fabric.js/master/dist/fabric.js"></script>  <canvas  width="400" height="400" id="canvascontainer"></canvas>  <img id="ten" style="border:2px solid;"/>

here can see have not provided src image. instead function converttoimage set source of image. here fiddle


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -