I am trying to figure out how to measure the length in pixels of an arbitrary line graphic. I know that if the graphic has only two points I could do some math with the pythagorean theorem to figure out the length of the line, but I would like for my user to be able to create a path of several points and have the program automatically calculate how long the line is.
For example:
Graphic with points
100,100 | 100,150 | 125,125 | 200, 200
would make a nice zig-zag.
Is there a built-in function that I am missing which would tell me the "length" of a line, or am I going to have to generate a function that parses each point of the line and adds up a bunch of pythagorean calculations?
Thanks
Measuring Distance & Length of a Graphic
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Measuring Distance & Length of a Graphic
Check out my LiveCode program, WriteSpire, on the App Store!
-
- VIP Livecode Opensource Backer
- Posts: 9648
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Measuring Distance & Length of a Graphic
Hi.
Polylines (and a short list of other graphics) have a property know as "the points". Read up on this in the dictionary. With this you can set (and create on the fly) the vertices of such an object to a return delimited list of x-y coordinates.
With that, you will have to do what you said, do the math for each segment. Knowing the screen resolution would allow you to translate pixel lengths into actual measurable lengths, if that is what you needed.
Craig Newman
Polylines (and a short list of other graphics) have a property know as "the points". Read up on this in the dictionary. With this you can set (and create on the fly) the vertices of such an object to a return delimited list of x-y coordinates.
With that, you will have to do what you said, do the math for each segment. Knowing the screen resolution would allow you to translate pixel lengths into actual measurable lengths, if that is what you needed.
Craig Newman