如何将像素转换为measurement-html5画布 [英] how to convert pixels into measurement-html5 canvas

查看:96
本文介绍了如何将像素转换为measurement-html5画布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我的画布反映了一些现实生活中的测量结果,比如8米乘6米,我画了一条线,我该如何计算画布上该线的测量值。即如果我从位置x1,y1到位置x2,y2绘制,我测量它并确定它大约是x长度。也可以在运行时在线下方显示测量值,就像我完成线后一样,它的长度自动显示在它的底部。我使用简单的画布,只有1个绘图线函数与javascript atm。

if my canvas is reflecting some real life measurements like 8 meter by 6 meter and i draw a line on it, how can i calculate the measurement of that line on canvas. i.e if i draw from position x1,y1 to position x2,y2 i measure it and say for sure that it is approximately x length long. Also will it be possible to show the measurement right below the line on runtime too like as soon as i finish the line,its length is automatically be shown at bottom of it. i am using simple canvas with just 1 draw line function with javascript atm.

推荐答案

要将像素转换为实时测量,首先需要知道显示器的DPI ,意味着它有多少个英寸点 - 这就是为什么它叫做DPI ...

不幸的是你无法通过JavaScript从操作系统获取这些信息...
To convert pixels to real time measurements you first need to know the DPI of your the monitor, means how many dots it have in inch - that's why it called DPI...
Unfortunately for you there is no way to get this info from OS using JavaScript...


这篇关于如何将像素转换为measurement-html5画布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆