code: def __init__(self, **kwargs):
      # Initialize the canvas for real
      app.Canvas.__init__(
          self, keys="interactive", size=(512, 512), **kwargs
      )
      ps = self.pixel_scale
      self.position = 50, 50
  
      n = 100
      ne = 100
      data = np.zeros(
          n,
          dtype=[
              ("a_position", np.float32, 3),
              ("a_fg_color", np.float32, 4),
              ("a_bg_color", np.float32, 4),
              ("a_size", np.float32),
              ("a_linewidth", np.float32),
          ],
      )
      edges = np.random.randint(size=(ne, 2), low=0, high=n).astype(
          np.uint32
      )
      data["a_position"] = np.hstack(
          (0.25 * np.random.randn(n, 2), np.zeros((n, 1)))
      )
      data["a_fg_color"] = 0, 0, 0, 1
      color = np.random.uniform(0.5, 1.0, (n, 3))
      data["a_bg_color"] = np.hstack((color, np.ones((n, 1))))
      data["a_size"] = np.random.randint(
          size=n, low=8 * ps, high=20 * ps
      )
      data["a_linewidth"] = 1.0 * ps
      u_antialias = 1
  
      self.vbo = gloo.VertexBuffer(data)
      self.index = gloo.IndexBuffer(edges)
      self.view = np.eye(4, dtype=np.float32)
      self.model = np.eye(4, dtype=np.float32)
      self.projection = np.eye(4, dtype=np.float32)
  
      self.program = gloo.Program(vert, frag)
      self.program.bind(self.vbo)
      self.program["u_size"] = 1
      self.program["u_antialias"] = u_antialias
      self.program["u_model"] = self.model
      self.program["u_view"] = self.view
      self.program["u_projection"] = self.projection
  
      set_viewport(0, 0, *self.physical_size)
  
      self.program_e = gloo.Program(vs, fs)
      self.program_e.bind(self.vbo)
  
      set_state(
          clear_color="white",
          depth_test=False,
          blend=True,
          blend_func=("src_alpha", "one_minus_src_alpha"),
      )
  
      self.show()
  
file_path: vispy/examples/demo/gloo/graph.py
imports: import numpy
  from vispy import gloo, app
  from vispy.gloo import set_viewport, set_state, clear
label_desc: Use image node_id 1 to create a new Canvas object from inherited base classes: app with example: obj = Canvas()