1

In javascript, we can draw a line in canvas with the length is in pixel. For example:

var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.beginPath();
ctx.moveTo(0,0);
ctx.lineTo(300,0);
ctx.stroke();

If I want to convert the length of the line to inch or milimeter, is there any way to do that?

Waveter
  • 890
  • 10
  • 22
  • 1
    So I project it onto a screen on the wall, one inch on my screen is now 3 feet.... Not sure how you would expect to get accurate measurements. – epascarello Nov 15 '18 at 16:57
  • @epascarello thats true :D but i think it is possible to evaluate the mm on a display because every information needed should be available – messerbill Nov 15 '18 at 16:58
  • You need to know the DPI of the screen/projector. https://uproer.com/articles/image-size-calculator-px-in/ – skyline3000 Nov 15 '18 at 17:15
  • 1
    for a resolution of 96dpi 1px = 0.264583333mm. In your case your line has a length of 300px. So 300 * 0.264583333 = 79.375mm – enxaneta Nov 15 '18 at 18:36

0 Answers0