How to use the vispy.app.Timer 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 / basics / visuals / modular_mesh.py View on Github external
# Lay out meshes in a grid
        grid = (3, 3)
        s = 300. / max(grid)
        for i, mesh in enumerate(self.meshes):
            x = 800. * (i % grid[0]) / grid[0] + 400. / grid[0] - 2
            y = 800. * (i // grid[1]) / grid[1] + 400. / grid[1] + 2
            mesh.transform = ChainTransform([STTransform(translate=(x, y),
                                                         scale=(s, s, 1)),
                                             self.rotation])
            mesh.tr_sys = visuals.transforms.TransformSystem(self)
            mesh.tr_sys.visual_to_document = mesh.transform

        self.show()

        self.timer = app.Timer(connect=self.rotate)
        self.timer.start(0.016)
github vispy / vispy / examples / basics / visuals / reactive_ellipse.py View on Github external
def __init__(self):
        self.ellipse = visuals.Ellipse(pos=(400, 400, 0), radius=[320, 240],
                                       color=(1, 0, 0, 1),
                                       border_color=(1, 1, 1, 1),
                                       start_angle=180., span_angle=150.)
        
        vispy.app.Canvas.__init__(self, keys='interactive')
        self.size = (800, 800)
        self.show()
        
        self._timer = app.Timer('auto', connect=self.on_timer, start=True)
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 genicam / harvesters / frontend / canvas.py View on Github external
]
        )
        self._data['a_texcoord'] = np.array(
            [[0., 1.], [1., 1.], [0., 0.], [1., 0.]]
        )

        #
        self._program['u_model'] = np.eye(4, dtype=np.float32)
        self._program['u_view'] = np.eye(4, dtype=np.float32)

        #
        self._translate = 0.
        self._latest_translate = self._translate

        #
        self._timer = app.Timer(1./fps, connect=self.update, start=True)

        #
        self._is_dragging = False
        self._coordinate = [0, 0]
        self._origin = [0, 0]

        # If it's True , the canvas keeps image acquisition but do not
        # draw images on the canvas.
        self._pause_drawing = False
github vispy / vispy / examples / basics / scene / colored_line.py View on Github external
color = next(colormaps)
line = scene.Line(pos=pos, color=color, method='gl')
line.transform = STTransform(translate=[0, 140])
line.parent = canvas.central_widget

text = scene.Text(color, bold=True, font_size=24, color='w',
                  pos=(200, 40), parent=canvas.central_widget)


def on_timer(event):
    global colormaps, line, text, pos
    color = next(colormaps)
    line.set_data(pos=pos, color=color)
    text.text = color

timer = app.Timer(.5, connect=on_timer, start=True)


if __name__ == '__main__':
    canvas.app.run()
github EtienneCmb / visbrain / visbrain / ndviz / visuals / NdpltMesh.py View on Github external
# Initialize the vispy.Visual class with the vertex / fragment buffer :
        # and OpenGL state :
        visuals.Visual.__init__(self, vertex_shader, fragment_shader)

        self.set_gl_state('translucent', depth_test=True, cull_face=False,
                          blend=True, blend_func=('src_alpha',
                                                  'one_minus_src_alpha'))
        self._draw_mode = 'line_strip'

        # --------------------------------------------------------------------
        # Set data :
        self.set_data(*args, **kwargs)

        # --------------------------------------------------------------------
        # Link the time the the on_time function :
        self._timer = app.Timer(1/self._sf, connect=self.on_timer,
                                start=False)

        self.freeze()
github portugueslab / stytra / stytra / stimulation / vispy_display.py View on Github external
self.txt = None
        self.prev_time = None
        self.stimuli = None
        self.current_stimulus = None
        self.canvas = None
        self.scene = None
        self.protocol = protocol()
        self.stimulus_elapsed = None
        self.i_stimulus = 0
        self.is_running = False
        vispy.use("PyQt5")
        self.canvas = scene.SceneCanvas(size=(800, 600), show=True)
        view = self.canvas.central_widget.add_view()
        self.scene = view.scene
        self.txt = scene.visuals.Text(parent=view.scene, color="white", pos=(40, 40))
        self.timer = vispy.app.Timer(interval=0.001, connect=self.update)
        self.start()
        self.interval = []
        vispy.app.run()
github vispy / vispy / examples / demo / gloo / brain.py View on Github external
self.theta, self.phi = -80, 180
        self.translate = 3

        self.faces = gloo.IndexBuffer(faces)
        self.program.bind(gloo.VertexBuffer(data))

        self.program['u_color'] = 1, 1, 1, 1
        self.program['u_light_position'] = (1., 1., 1.)
        self.program['u_light_intensity'] = (1., 1., 1.)

        self.apply_zoom()

        gloo.set_state(blend=False, depth_test=True, polygon_offset_fill=True)

        self._t0 = default_timer()
        self._timer = app.Timer('auto', connect=self.on_timer, start=True)

        self.update_matrices()
github alexjc / shadertoy-render / shadertoy-render.py View on Github external
def ensure_timer(self):
        if not self._timer:
            self._timer = app.Timer('auto' if self._ffmpeg_pipe else self._interval,
                                    connect=self.on_timer,
                                    start=True)
github vispy / vispy / examples / demo / visuals / wiggly_bar.py View on Github external
)
        self.mass.transform = transforms.MatrixTransform()
        self.mass.transform.scale((self.scale, self.scale, 0.0001))
        self.mass.transform.translate(self.center + self.mass_loc)

        # Append all the visuals
        self.visuals.append(self.center_point)
        self.visuals.append(self.rod)
        self.visuals.append(self.spring_2)
        self.visuals.append(self.spring_1)
        self.visuals.append(self.mass)
        self.visuals.append(self.text)
        self.visuals.append(self.method_text)

        # Set up a timer to update the image and give a real-time rendering
        self._timer = app.Timer('auto', connect=self.on_timer, start=True)