tldraw / tldraw

SDK for creating whiteboards and canvas experiences on the web.

Home Page:https://tldraw.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how to convert between coordinates

bumberboy opened this issue · comments

Hello team

Thanks for the amazing project!

I've 2 questions that I hope I can get help with:

  1. I'm trying to get the stroke paths for the drawn shapes. However I notice that there are negative numbers within the segments. What is the best way to convert them into a different coordinate system with the origin at the corners such that x and y are always positive?

  2. what's the difference in these ways of obtaining the points of the path:

shape.props.segments vs shapeUtil.getGeometry(shape).getVertices()

The outputs look different.

alright figured it out. I just had to add in the shape's x and y. The vertices's origins are the first point of the stroke. WIll close this for now.