Get point's y coordinate on svg path

前端 未结 3 1340
悲&欢浪女
悲&欢浪女 2021-02-10 16:35

I guess I need to add some explanation, that I want to ask this question, because too short question doesn\'t quality standards... funny...

So, here is the question: How

3条回答
  •  庸人自扰
    2021-02-10 16:51

    If you know all the points of your path, I believe a more performant solution than stepping through the path might be to search the d attribute of your path for the specific x coordinate you are looking for. Then capture the y coordinate using regexp. The regexp could be used like so:

    const regex = new RegExp(`${x} ((\d*.\d*))`)
    const match = regex.exec(d)
    

提交回复
热议问题