Understanding path/segment/item data structure

53 views
Skip to first unread message

Colin Kingsbury

unread,
May 12, 2013, 10:42:32 PM5/12/13
to pap...@googlegroups.com
I am working on a prototype which involves interactive drawing and editing of paths. I'm slowly getting things to work and having some real fun, but I am still having some difficulty understanding how to navigate some of the basic data structures.

Here is a sketch of a path consisting of three straight lines:


If I do a Project.HitTest for a point along B, I get a HitResult with type=stroke, item=my path, segment=null. How do I determine which segment in my path I clicked (i.e. "B") and get the two points at either end (2 and 3)?

More generally, I am trying to understand how paths, segments, and curves actually fit together in terms of the data model. From reading the docs I see that a path has multiple segments which makes sense, but that a segment only has one point (its anchor point?). If I inspect a simple line (straight line between two points) in a debugger I see that its path actually consists of two segments where each segment contains one endpoint.

Is there anything anywhere I could read which explains the principle behind this a little more clearly? Or can anyone shed a little light?

Thanks in advance!
Screen Shot 2013-05-12 at 10.15.10 PM.png
Reply all
Reply to author
Forward
0 new messages