How to use the vispy.app.Canvas.__init__ function in vispy

To help you get started, we’ve selected a few vispy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vispy / vispy / examples / tutorial / app / app_glfw.py View on Github external
def __init__(self, *args, **kwargs):
        app.Canvas.__init__(self, *args, **kwargs)
        timer = app.Timer(1.0)
        timer.connect(self.on_timer)
        timer.start()
github vispy / vispy / examples / demo / gloo / jfa / jfa_vispy.py View on Github external
def __init__(self):
        self.use_shaders = True
        app.Canvas.__init__(self, size=(512, 512), keys='interactive')
        # Note: read as bytes, then decode; py2.6 compat
        with open(op.join(this_dir, 'vertex_vispy.glsl'), 'rb') as fid:
            vert = fid.read().decode('ASCII')
        with open(op.join(this_dir, 'fragment_seed.glsl'), 'rb') as f:
            frag_seed = f.read().decode('ASCII')
        with open(op.join(this_dir, 'fragment_flood.glsl'), 'rb') as f:
            frag_flood = f.read().decode('ASCII')
        with open(op.join(this_dir, 'fragment_display.glsl'), 'rb') as f:
            frag_display = f.read().decode('ASCII')
        self.programs = [Program(vert, frag_seed),
                         Program(vert, frag_flood),
                         Program(vert, frag_display)]
        # Initialize variables
        # using two FBs slightly faster than switching on one
        self.fbo_to = [FrameBuffer(), FrameBuffer()]
        self._setup_textures('shape1.tga')
github vispy / vispy / examples / basics / gloo / hello_fbo.py View on Github external
def __init__(self):
        app.Canvas.__init__(self, keys='interactive', size=(560, 420))

        # Create texture to render to
        shape = self.physical_size[1], self.physical_size[0]
        self._rendertex = gloo.Texture2D((shape + (3,)))

        # Create FBO, attach the color buffer and depth buffer
        self._fbo = gloo.FrameBuffer(self._rendertex, gloo.RenderBuffer(shape))

        # Create program to render a shape
        self._program1 = gloo.Program(VERT_SHADER1, FRAG_SHADER1)
        self._program1['u_color'] = 0.9, 1.0, 0.4, 1
        self._program1['a_position'] = gloo.VertexBuffer(vPosition)

        # Create program to render FBO result
        self._program2 = gloo.Program(VERT_SHADER2, FRAG_SHADER2)
        self._program2['a_position'] = gloo.VertexBuffer(vPosition)
github strfry / OpenNFB / blocks / waterfall.py View on Github external
def __init__(self):
        app.Canvas.__init__(self, title='Use your wheel to zoom!',
                            keys='interactive')

        self.program = gloo.Program(VERT_SHADER, FRAG_SHADER)
        self.program['index'] = [(x,) for x in range(num_bins)] * num_lines
        self.program['line'] = [(x,) * num_bins for x in range(num_lines)]
        self.program['map_offset'] = 0

        self.program['num_bins'] = num_bins
        self.program['num_lines'] = num_lines

        heightmap = np.random.random(size=(num_lines, num_bins)).astype('float32')

        self.program['heightmap'] = gloo.Texture2D(data=heightmap, internalformat='r32f')
        #print (dir(self.program['heightmap']))

        self.program['colormap'] = Colormap(['r', 'g', 'b']).map(np.linspace(0, 1, 64)).astype('float32')
github vispy / vispy / examples / demo / gloo / terrain.py View on Github external
def __init__(self):
        app.Canvas.__init__(self, keys='interactive')
        self.program = gloo.Program(VERT_SHADER, FRAG_SHADER)
        # Sets the view to an appropriate position over the terrain
        self.default_view = np.array([[0.8, 0.2, -0.48, 0],
                                     [-0.5, 0.3, -0.78, 0],
                                     [-0.01, 0.9, -0.3, 0],
                                     [-4.5, -21.5, -7.4, 1]],
                                     dtype=np.float32)
        self.view = self.default_view
        self.model = np.eye(4, dtype=np.float32)
        self.projection = np.eye(4, dtype=np.float32)

        self.translate = [0, 0, 0]
        self.rotate = [0, 0, 0]

        self.program['u_height'] = height
        self.program['u_model'] = self.model
github vispy / vispy / examples / rawgl / rawgl-cube.py View on Github external
def __init__(self):
        app.Canvas.__init__(self)
        self.size = 400, 400
        self.init_transforms()

        self.timer = app.Timer(1.0 / 60)
        self.timer.connect(self.update_transforms)
        self.timer.start()
github vispy / vispy / examples / tutorial / app / app_sdl2.py View on Github external
def __init__(self, *args, **kwargs):
        app.Canvas.__init__(self, *args, **kwargs)
        timer = app.Timer(1.0)
        timer.connect(self.on_timer)
        timer.start()
github vispy / vispy / examples / basics / visuals / text_scatter.py View on Github external
def __init__(self):
        app.Canvas.__init__(self, keys='interactive',
                            size=(800, 800))

        self.n_iterations = 0

        self.text_parts = [
            'This',
            'is',
            'a',
            'multicolored',
            'scattered',
            'text']

        self.x = 100 + np.arange(len(self.text_parts))*100
        self.y = 400 + (np.sin(2 * np.pi * (self.x/self.x[-1]))*100)

        self.text_positions = np.c_[self.x, self.y]
github vispy / vispy / examples / tutorial / app / fps.py View on Github external
def __init__(self, *args, **kwargs):
        app.Canvas.__init__(self, *args, **kwargs)
        self.show()
github vispy / vispy / examples / tutorial / gl / quad.py View on Github external
def __init__(self):
        app.Canvas.__init__(self, size=(512, 512), title='Quad (GL)',
                            keys='interactive')