code: def triangulate(P):
      n = len(P)
      S = np.repeat(np.arange(n + 1), 2)[1:-1]
      S[-2:] = n - 1, 0
      S = S.reshape(len(S) // 2, 2)
      T = Triangulation(P[:, :2], S)
      T.triangulate()
      points = T.pts
      triangles = T.tris.ravel()
      P = np.zeros((len(points), 3), dtype=np.float32)
      P[:, :2] = points
      return P, triangles
  
file_path: vispy/examples/collections/triangle_collection.py
imports: import numpy
  from vispy import app, gloo
  from vispy.geometry import Triangulation
  from vispy.visuals.collections import PathCollection, TriangleCollection
label_desc: Use image node_id 1 for calling a global function with example usage: triangulate(P) and returns: P,  triangles