[英]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.