首页 > 技术文章 > javascript 获取两点的像素距离

weihexinCode 2020-02-16 16:55 原文

1 getPosLen(sdot, edot){//获取2点距离
2         /* 
3         56 40 56
4         40 00 40
5         56 40 56
6         */
7         return parseInt(Math.sqrt(Math.pow(Math.abs(sdot.x - edot.x), 2) + Math.pow(Math.abs(sdot.y - edot.y), 2)));
8 }

 

推荐阅读