code: def render(self, region=None, size=None, bgcolor=None):
          
          self.set_current()
          # Set up a framebuffer to render to
          offset = (0, 0) if region is None else region[:2]
          csize = self.size if region is None else region[2:]
          s = self.pixel_scale
          size = tuple([x * s for x in csize]) if size is None else size
          fbo = gloo.FrameBuffer(color=gloo.RenderBuffer(size[::-1]),
                                 depth=gloo.RenderBuffer(size[::-1]))
  
          self.push_fbo(fbo, offset, csize)
          try:
              self._draw_scene(bgcolor=bgcolor)
              return fbo.read()
          finally:
              self.pop_fbo()
docs: Render the scene to an offscreen buffer and return the image array.
          
          Parameters
          ----------
          region : tuple | None
              Specifies the region of the canvas to render. Format is 
              (x, y, w, h). By default, the entire canvas is rendered.
          size : tuple | None
              Specifies the size of the image array to return. If no size is 
              given, then the size of the *region* is used, multiplied by the 
              pixel scaling factor of the canvas (see `pixel_scale`). This
              argument allows the scene to be rendered at resolutions different
              from the native canvas resolution.
          bgcolor : instance of Color | None
              The background color to use.
  
          Returns
          -------
          image : array
              Numpy array of type ubyte and shape (h, w, 4). Index [0, 0] is the 
              upper-left corner of the rendered region.