First node has last index instead of 0

I always thought that first node (triangle icon) have index 0. Is it correct? Now I’m noticed that the node with triangle icon have last index of the path, and the next node have index 0. Also, If I use path.makeNodeFirst_(node), this first node (with triangle icon) have last index instead of 0. I’m not remember if it was the normal behaviour, or is it changed in latest versions?

1 Like

It was always like this.

Oh, it’s good to know.
What was the intention of this logic? I mean, why the first node is not the node with index 0?

If you have a list of nodes:

414 74 offcurve,
496 182 offcurve,
496 316 curve,
496 450 offcurve,
414 558 offcurve,
312 558 curve,
210 558 offcurve,
128 450 offcurve,
128 316 curve,
128 182 offcurve,
210 74 offcurve,
312 74 curve

Then the first segments starts at the last node. So that is marked as the start of the path.
One could more the last node to the beginning of the list but that would have other drawbacks.

I see. As I understand now, it is due to:

  1. How segment type is determined by the last node of segment.
  2. If path is closed or open.

The last node of segment (on-curve) contains the type of segment (line or curve).

  • For open path, first node always has 0 index.
  • For closed path, it is a question – what the node is in the connection point – last or first. So, visually, this last-first node considered the First node and has a triangle icon. But for internal logic, this node has last index, because it is the ending node of its segment.

Is my understanding correct?

Yes.
For open paths, you can consider the first node to be a moveTo command/segment.

2 Likes