code: def splitLine(pt1, pt2, where, isHorizontal):
      """Split a line at a given coordinate.
  
      Args:
          pt1: Start point of line as 2D tuple.
          pt2: End point of line as 2D tuple.
          where: Position at which to split the line.
          isHorizontal: Direction of the ray splitting the line. If true,
              ``where`` is interpreted as a Y coordinate; if false, then
              ``where`` is interpreted as an X coordinate.
  
      Returns:
          A list of two line segments (each line segment being two 2D tuples)
          if the line was successfully split, or a list containing the original
          line.
  
      Example::
  
          >>> printSegments(splitLine((0, 0), (100, 100), 50, True))
          ((0, 0), (50, 50))
          ((50, 50), (100, 100))
          >>> printSegments(splitLine((0, 0), (100, 100), 100, True))
          ((0, 0), (100, 100))
          >>> printSegments(splitLine((0, 0), (100, 100), 0, True))
          ((0, 0), (0, 0))
          ((0, 0), (100, 100))
          >>> printSegments(splitLine((0, 0), (100, 100), 0, False))
          ((0, 0), (0, 0))
          ((0, 0), (100, 100))
          >>> printSegments(splitLine((100, 0), (0, 0), 50, False))
          ((100, 0), (50, 0))
          ((50, 0), (0, 0))
          >>> printSegments(splitLine((0, 100), (0, 0), 50, True))
          ((0, 100), (0, 50))
          ((0, 50), (0, 0))
      """
      pt1x, pt1y = pt1
      pt2x, pt2y = pt2
  
      ax = pt2x - pt1x
      ay = pt2y - pt1y
  
      bx = pt1x
      by = pt1y
  
      a = (ax, ay)[isHorizontal]
  
      if a == 0:
          return [(pt1, pt2)]
      t = (where - (bx, by)[isHorizontal]) / a
      if 0 <= t < 1:
          midPt = ax * t + bx, ay * t + by
          return [(pt1, midPt), (midPt, pt2)]
      else:
          return [(pt1, pt2)]
  
imports: from fontTools.misc.arrayTools import calcBounds, sectRect, rectArea
  from fontTools.misc.transform import Identity
  import math
  from collections import namedtuple
  from math import sqrt, acos, cos, pi
label_desc: Use image node_id 15 for calling a global function with example usage: splitLine(pt1, pt2, where, isHorizontal) and returns: list, list, list