code: def __init__(
      self,
      field,
      spacing=10,
      segments=3,
      seg_len=0.5,
      color=(1, 1, 1, 0.3),
  ):
      self._time = 0.0
      self._last_time = ptime.time()
      rows = int(field.shape[0] / spacing)
      cols = int(field.shape[1] / spacing)
      index = np.empty(
          (rows * cols, int(segments) * 2, 2), dtype=np.float32
      )
  
      # encodes starting position within vector field
      index[:, :, 0] = np.arange(rows * cols)[:, np.newaxis]
      # encodes distance along length of line
      index[:, ::2, 1] = np.arange(segments)[np.newaxis, :]
      index[:, 1::2, 1] = np.arange(segments)[np.newaxis, :] + 1
      self._index = gloo.VertexBuffer(index)
      if not isinstance(color, np.ndarray):
          color = np.array([[list(color)]], dtype="float32")
      self._color = gloo.Texture2D(color)
  
      offset = np.random.uniform(256, size=(rows, cols, 3)).astype(
          np.ubyte
      )
      self._offset = gloo.Texture2D(offset, format="rgb")
      self._field = gloo.Texture2D(
          field,
          format="rg",
          internalformat="rg32f",
          interpolation="linear",
      )
      self._field_shape = field.shape[:2]
  
      visuals.Visual.__init__(
          self, vcode=self.vertex, fcode=self.fragment
      )
      self.timer = app.Timer(
          interval="auto", connect=self.update_time, start=False
      )
      self.freeze()
  
      self.shared_program["field"] = self._field
      self.shared_program["field_shape"] = self._field.shape[:2]
      self.shared_program["shape"] = (rows, cols)
      self.shared_program["index"] = self._index
      self.shared_program["spacing"] = spacing
      self.shared_program["t"] = self._time
      self.shared_program["offset"] = self._offset
      self.shared_program["speed"] = 1
      self.shared_program["color"] = self._color
      self.shared_program["seg_len"] = seg_len
      self.shared_program["nseg"] = segments
      self.shared_program["n_iter"] = 1
      self.shared_program["attractor"] = (0, 0)
      self.shared_program["time"] = 0
      self._draw_mode = "lines"
      self.set_gl_state("translucent", depth_test=False)
  
      self.timer.start()
  
file_path: vispy/examples/demo/scene/flow_lines.py
imports: from __future__ import division
  from vispy import app, scene, visuals, gloo
  from vispy.util import ptime
  import numpy
label_desc: Use image node_id 1 to create a new VectorFieldVisual object from inherited base classes: visuals with example: obj = VectorFieldVisual(field, spacing, segments, seg_len, color)