konvajs / konva

Konva.js is an HTML5 Canvas JavaScript framework that extends the 2d context by enabling canvas interactivity for desktop and mobile applications.
http://konvajs.org/
Other
11.72k stars 934 forks source link

How Polotno resizes the stage #1782

Closed liganghui closed 5 months ago

liganghui commented 5 months ago

I tried Polotno, it's really great! I found that it can resize the canvas, but the width and height of the konvajs-content canvas element are not changed. This is different from konva . How is this done ? Can you make a demo? Or explain the principle? Thanks !!

lavrton commented 5 months ago

It is just a simple scaling of a content. group.scaleX(scalingFactor), where scalingFactor is calculated from available size.

It is very similar to https://konvajs.org/docs/sandbox/Responsive_Canvas.html.

"Resize canvas" in that context should be worded as "resize page" and "resize page" is not equal to "resize canvas element".