docs: def generate_unit_triangles(image_width, image_height):
      """Generate coordinates for a tiling of unit triangles."""
      # Our triangles lie with one side parallel to the x-axis.  Let s be
      # the length of one side, and h the height of the triangle.
      #
      # The for loops (x, y) gives the coordinates of the top left-hand corner
      # of a pair of triangles:
      #
      #           (x, y) +-----+ (x + 1, y)
      #                   \   / \
      #                    \ /   \
      #    (x + 1/2, y + h) +-----+ (x + 3/2, y + h)
      #
      # where h = sin(60°) is the height of an equilateral triangle with
      # side length 1.
      #
      # On odd-numbered rows, we translate by (s/2, 0) to make the triangles
      # line up with the even-numbered rows.
      #
      # To avoid blank spaces on the edge of the canvas, the first pair of
      # triangles on each row starts at (-1, 0) -- one width before the edge
      # of the canvas.
      h = math.sin(math.pi / 3)
  
      for x in range(-1, image_width):
          for y in range(int(image_height / h)):
  
              # Add a horizontal offset on odd numbered rows
              x_ = x if (y % 2 == 0) else x + 0.5
  
              yield [(x_, y * h), (x_ + 1, y * h), (x_ + 0.5, (y + 1) * h)]
              yield [(x_ + 1, y * h), (x_ + 1.5, (y + 1) * h),
                     (x_ + 0.5, (y + 1) * h)]