Extend/Trim Lines to a Reference Line

This example extends lines to end at a reference line. It also trims the lines to either the cw or ccw side of the reference line.
Trimmed Side   cw: ccw:

SVG Extend Source:

SVG Trim Source:

Javascript:
OK in:IE11/CH32/FF23