Resize canvas using js cloth

The application allows the user to save the design and post it so that other users can view it later.

The original canvas was saved with the proportions width = 700 and height = 600. But when displaying the canvas, I want to resize the canvas so that it fits in the dimensions (350 300). half of the original. But if I directly apply these sizes and load widths to setWidth () and setHeight (), it loads with the original proportions.

All I want to do is show the canvas with new dimensions.

+5
source share
2 answers

Previously posted here .

I'm not sure what you tried, but

var canvas = document.getElementsByTagName('canvas')[0];
canvas.width  = 800;
canvas.height = 600;

should work fine.

-3
source

fabric.js, .

, "canvas" - fabric.js, , :

canvas.setWidth( <desired width> );
canvas.setHeight( <desired height> );
canvas.calcOffset();
+38

All Articles