简体   繁体   English

有什么方法可以检测javascript中字母的最低点吗?

[英]Is there any way to detect lowest point of a letter in javascript?

I've been playing with JS/jQuery recently and I'm trying to make a physical model of letters with gravity etc. For proper collision of a letter with ground, I need to find coordinates of the lowest point of a rotated letter - the one which touches the bottom of the screen at the moment of collision to calculate angles. 我最近一直在使用JS / jQuery,正在尝试创建具有重力等作用的字母的物理模型。为了使字母与地面正确碰撞,我需要找到旋转字母的最低点的坐标-一个在发生碰撞时触碰屏幕底部以计算角度的角度。

I have an idea which oversimplifies it - to create a rectangular hitbox of the letter, which is known. 我有一个过分简化的想法-创建字母的矩形点击框,这是众所周知的。 Actually, for some letters like A, which is fairly triangular, one can design custom shaped hitbox, but it is manual and not exact, and implementing triangle in javascript doesn't seem easy. 实际上,对于像A这样的相当三角形的字母,可以设计自定义形状的Hitbox,但是它是手动的而不是精确的,并且在JavaScript中实现三角形似乎并不容易。

I don't need the code, just wanted to hear some ideas, the general approach. 我不需要代码,只是想听听一些想法,一般的方法。

Thank you 谢谢

You want to use canvas, write letter onto it and then inspect pixels positions and do calculus. 您要使用画布,在画布上写字母,然后检查像素位置并进行微积分。 Dont know the specs but that way not only could you find the lowest point but also a center of mass and an angle which i can see both as relevant for gravity/ricochet calculation. 不知道规格,但那样一来,您不仅可以找到最低点,而且可以找到质心和角度,我认为这与重力/弹跳计算都相关。

Additionally, you might want to pay attention to performance based on number of letters you need for your project. 此外,您可能想根据项目所需的字母数来关注性能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 JavaScript / jQuery-是否可以检测点击类型? - JavaScript / jQuery - Any way to detect click type? 有什么方法可以使用JavaScript检测“强制点击”吗? - Any way to detect Force Click with Javascript? 有没有办法检测用户在javascript弹出窗口中的点击? - Is there any way to detect user clicks in the javascript popup? JavaScript:正则表达式为一个字母和一个点 - JavaScript: Regex for one letter and a point 在Javascript中检测字符串中的重复字母 - Detect repeating letter in an string in Javascript 有什么方法可以在数组内部计算 min arrays 并返回每个数组中数字最小的数组? Javascript - Is there any way to math min arrays inside array and return a array with the lowest numbers in each array? Javascript Javascript:有什么方法可以检测所有异步脚本何时加载? - Javascript: Is there any way to detect when all async scripts have loaded? 在IE中使用JavaScript的Windows中可以使用任何检测URI模式的方法 - Any way to detect URI schema is available in windows using JavaScript in IE 在javascript中是否有一种方法可以检测元素是否附加了任何事件? - Is there a way in javascript to detect if an element has any events attached to it? javascript中有什么方法可以检测用户在文本输入框中输入的语言? - is there any way in javascript to detect the language entered by the user in a text inpout box?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM