It propably wouldn't look too bad if the delta (0..1) would be calculated from function ClosestPointOnLine for each segment. Even if it's just a temporary fix