Konvajs how to set the Stage size to millimeter (mm) instead of pixel (px)?

63 Views Asked by At

Konvajs how to set the Stage size to millimeter (mm) instead of pixel (px) ? Without manually change the canvas size with js.

Based on the doc https://konvajs.org/api/Konva.Stage.html the width and height is in Number, which I assumed is only on px

width   Number  <optional>
height  Number  <optional>
var stage = new Konva.Stage({
  width: 500,
  height: 800,
  container: 'containerId' // or "#containerId" or ".containerClass"
});
1

There are 1 best solutions below

0
Vanquished Wombat On

No it is not possible to use mm for canvas or Konva. What you need to do is decide on a mm scale and compute how many px per mm you will use to represent that. You can then convert between px and mm easily, show rulers or measurements etc. This is how all drawing apps work. Note that this is not a simple thing to do because of the pixel density of different devices, for example retina displays have a higher number of px per inch than others.