Sure, it does use a few different of methods:
pos = l.toComp(p.pointOnPath(tr/100) + extra_margin);
p was a reference to the shape of the line you drew (path)
tr was a reference to how far the End-parameter of the trim Paths Effect was set.
p.pointOnPath() = is a method that returns the pixel coordinates of a point along a given path (p).
At 0 it’ll give the position of the vertex, at 1.0 the position of the last vertex (or the first again, if the path is closed), and in between it’ll give points along the path.
It is very close to what “Trim Paths” does visually, but gives us coordinates.
Trim Path however goes from 0-100, so we divide by 100 to get values between 0 an 1.0
p.pointOnPath(tr/100) + extra_margin -> this would give us the pixel coordinates of where the line stops + some extra pixels higher (extra margin).
However: these coordinates are relative to the layer the path is on, we cannot just use this coordinate for another layer ‘s position and suppose they are the same: the layer where the coordinates comes from could be sacled, rotated, parented,… for every layer an ‘internal’ coordinate like [100,100] can mean a totally different pixel on screen.
layer.toComp([x,y]) fixes this: it is a “layer space transform method” that gives us the actual position in the comp of a position ‘inside’ of a layer.
There might be other factors of why that position would still note work as the precise position for another layer (if it’s parented form example), but that is fixed in the next line with a fromComp(), which does the inverse of toComp()