当前位置: 首页>>代码示例>>Python>>正文


Python gloo.clear函数代码示例

本文整理汇总了Python中vispy.gloo.clear函数的典型用法代码示例。如果您正苦于以下问题:Python clear函数的具体用法?Python clear怎么用?Python clear使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了clear函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: paintGL

 def paintGL(self):
     """ docstring """
     self._mutex.acquire()
     GL.glViewport(0,0,DEFAULT_SHAPE[0],DEFAULT_SHAPE[1])
     gloo.clear(color=True, depth=True,stencil=True)
     self._chosenAlgo.timedUpdate()
     self._mutex.release()
开发者ID:PierreGe,项目名称:ba3-project,代码行数:7,代码来源:OpenGLWidget.py

示例2: test_reactive_draw

def test_reactive_draw():
    """Test reactive RectPolygon attributes"""
    with TestingCanvas() as c:
        rectpolygon = visuals.Rectangle(pos=(50, 50, 0), height=40.,
                                        width=80., color='red')
        c.draw_visual(rectpolygon)

        gloo.clear()
        rectpolygon.radius = [20., 20, 0., 10.]
        c.draw_visual(rectpolygon)
        assert_image_equal("screenshot", 'visuals/reactive_rectpolygon1.png')

        gloo.clear()
        rectpolygon.pos = (60, 60, 0)
        c.draw_visual(rectpolygon)
        assert_image_equal("screenshot", 'visuals/reactive_rectpolygon2.png')

        gloo.clear()
        rectpolygon.color = 'blue'
        c.draw_visual(rectpolygon)
        assert_image_equal("screenshot", 'visuals/reactive_rectpolygon3.png')

        gloo.clear()
        rectpolygon.border_color = 'yellow'
        c.draw_visual(rectpolygon)
        assert_image_equal("screenshot", 'visuals/reactive_rectpolygon4.png')

        gloo.clear()
        rectpolygon.radius = 10.
        c.draw_visual(rectpolygon)
        assert_image_equal("screenshot", 'visuals/reactive_rectpolygon5.png')
开发者ID:rossant,项目名称:vispy,代码行数:31,代码来源:test_rectangle.py

示例3: test_ellipse_draw

def test_ellipse_draw():
    """Test drawing transformed ellipses using EllipseVisual"""
    with TestingCanvas() as c:
        ellipse = visuals.Ellipse(pos=(0., 0.), radius=(20, 15),
                                  color=(0, 0, 1, 1))
        ellipse.transform = transforms.STTransform(scale=(2.0, 3.0),
                                                   translate=(50, 50))
        c.draw_visual(ellipse)
        assert_image_equal("screenshot", 'visuals/ellipse1.png')

        gloo.clear()
        ellipse = visuals.Ellipse(pos=(0., 0.), radius=(20, 15),
                                  color=(0, 0, 1, 1),
                                  border_color=(1, 0, 0, 1))
        ellipse.transform = transforms.STTransform(scale=(2.0, 3.0),
                                                   translate=(50, 50))
        c.draw_visual(ellipse)
        assert_image_equal("screenshot", 'visuals/ellipse2.png')

        gloo.clear()
        ellipse = visuals.Ellipse(pos=(0., 0.), radius=(20, 15),
                                  border_color=(1, 0, 0, 1))
        ellipse.transform = transforms.STTransform(scale=(2.0, 3.0),
                                                   translate=(50, 50))
        c.draw_visual(ellipse)
        assert_image_equal("screenshot", 'visuals/ellipse3.png')
开发者ID:rossant,项目名称:vispy,代码行数:26,代码来源:test_ellipse.py

示例4: on_draw

    def on_draw(self, event):
      gloo.clear()
      gloo.set_viewport(0, 0, self.camera.width, self.camera.height)

      self.program['u_light_position'] = [100., 100., 500.]
      self.program['u_is_lighting'] = True
      self.program['u_model'] = self.camera.model
      self.program['u_normal'] = self.camera.rotation 
      self.program['u_view'] = self.camera.view
      self.program['u_projection'] = self.camera.projection
      self.program['u_is_fog'] = self.camera.is_fog
      self.program['u_fog_far'] = self.camera.fog_far
      self.program['u_fog_near'] = self.camera.fog_near
      self.program['u_fog_color'] = self.camera.fog_color

      gl.glEnable(gl.GL_BLEND)
      gl.glEnable(gl.GL_DEPTH_TEST)
      gl.glDepthFunc(gl.GL_LEQUAL)
      gl.glCullFace(gl.GL_FRONT)
      gl.glEnable(gl.GL_CULL_FACE)

      self.draw_buffers(self.program)

      gl.glDisable(gl.GL_BLEND)
      gl.glDisable(gl.GL_DEPTH_TEST)
      gl.glDisable(gl.GL_CULL_FACE)

      self.console.draw()

      self.last_draw = 'screen'

      self.update()
开发者ID:boscoh,项目名称:pyball,代码行数:32,代码来源:pyball.py

示例5: on_draw

 def on_draw(self, event):
     """Draw the visual."""
     gloo.clear(color=True, depth=True)
     if self._show_mean:
         self.mean.draw()
     else:
         self.visual.draw()
开发者ID:Peichao,项目名称:phy,代码行数:7,代码来源:waveforms.py

示例6: test_use_framebuffer

def test_use_framebuffer():
    """Test drawing to a framebuffer"""
    shape = (100, 300)  # for some reason Windows wants a tall window...
    data = np.random.rand(*shape).astype(np.float32)
    use_shape = shape + (3,)
    with Canvas(size=shape[::-1]) as c:
        orig_tex = Texture2D(data)
        fbo_tex = Texture2D(use_shape, format='rgb')
        rbo = RenderBuffer(shape, 'color')
        fbo = FrameBuffer(color=fbo_tex)
        c.context.glir.set_verbose(True)
        assert_equal(c.size, shape[::-1])
        set_viewport((0, 0) + c.size)
        with fbo:
            draw_texture(orig_tex)
        draw_texture(fbo_tex)
        out_tex = _screenshot()[::-1, :, 0].astype(np.float32)
        assert_equal(out_tex.shape, c.size[::-1])
        assert_raises(TypeError, FrameBuffer.color_buffer.fset, fbo, 1.)
        assert_raises(TypeError, FrameBuffer.depth_buffer.fset, fbo, 1.)
        assert_raises(TypeError, FrameBuffer.stencil_buffer.fset, fbo, 1.)
        fbo.color_buffer = rbo
        fbo.depth_buffer = RenderBuffer(shape)
        fbo.stencil_buffer = None
        print((fbo.color_buffer, fbo.depth_buffer, fbo.stencil_buffer))
        clear(color='black')
        with fbo:
            clear(color='black')
            draw_texture(orig_tex)
            out_rbo = _screenshot()[:, :, 0].astype(np.float32)
    assert_allclose(data * 255., out_tex, atol=1)
    assert_allclose(data * 255., out_rbo, atol=1)
开发者ID:Calvarez20,项目名称:vispy,代码行数:32,代码来源:test_use_gloo.py

示例7: test_regular_polygon_draw2

def test_regular_polygon_draw2():
    """Test drawing transformed regular polygons using RegularPolygonVisual"""  # noqa
    with TestingCanvas() as c:
        rpolygon = visuals.RegularPolygon(pos=(0., 0.), radius=0.4, sides=8,
                                          color=(0, 0, 1, 1))
        rpolygon.transform = transforms.STTransform(scale=(75, 100),
                                                    translate=(50, 50))
        c.draw_visual(rpolygon)
        assert_image_equal("screenshot", 'visuals/regular_polygon4.png')

        gloo.clear()
        rpolygon = visuals.RegularPolygon(pos=(0., 0.), radius=0.4, sides=8,
                                          color=(0, 0, 1, 1),
                                          border_color=(1, 0, 0, 1))
        rpolygon.transform = transforms.STTransform(scale=(75, 100),
                                                    translate=(50, 50))
        c.draw_visual(rpolygon)
        assert_image_equal("screenshot", 'visuals/regular_polygon5.png')

        gloo.clear()
        rpolygon = visuals.RegularPolygon(pos=(0., 0.), radius=0.4, sides=8,
                                          border_color=(1, 0, 0, 1))
        rpolygon.transform = transforms.STTransform(scale=(75, 100),
                                                    translate=(50, 50))
        c.draw_visual(rpolygon)
        assert_image_equal("screenshot", 'visuals/regular_polygon6.png', 0.6)
开发者ID:zhangweiabc,项目名称:vispy,代码行数:26,代码来源:test_regular_polygon.py

示例8: draw

	def draw(self, event):
		#Turn on additive blending
		gloo.set_state('additive')
		gloo.clear()
		#Summary render to main screen
		if self.state == 'texture' or self.state == 'raw':
			self._program.draw('triangles', self.indices_buffer)
		elif self.state == 'flow':
			self._program_flow.bind(self._vbo)
			self._program_flow.draw('triangles', self.indices_buffer)
		elif self.state == 'mask':
			self._program_mask.bind(self._vbo)
			#self._updatemaskpalette(np.squeeze(self.randfacecolors[:,:,0]))
			#self._updatemaskpalette(np.squeeze(self.randhessfacecolors[:,:,1]))
			self._updatemaskpalette(np.squeeze(self.hessfacecolors[:,:,1]))
			#print self._program_mask['u_colors']#self.randfacecolors[:,:,0]
			self._program_mask.draw('triangles', self.indices_buffer)			
		elif self.state == 'overlay':
			self._program_red['texture1'] = self.current_texture
			self._program_red.bind(self._quad)
			self._program_red.draw('triangles', self.quad_buffer)
			self._program_green.bind(self._vbo)
			self._program_green['texture1'] = self.init_texture
			self._program_green.draw('triangles', self.indices_buffer)
		else:
			self._program_outline.bind(self._vbo)
			self._program_outline.draw('lines', self.outline_buffer)
		#Draw wireframe, too
		if self.state != 'raw' and self.state != 'outline':
			self._program_lines.draw('lines', self.outline_buffer)
开发者ID:benlansdell,项目名称:hydra,代码行数:30,代码来源:renderer.py

示例9: on_draw

 def on_draw(self, event):
     '''TODO:
         Make a better way to skip drawing...this is a hack at best
     '''
     gloo.set_viewport(0, 0, *self.size)
     gloo.clear(color=True, depth=True)
     self.rendering_world.draw(self.view)
开发者ID:APCarney,项目名称:Sub8,代码行数:7,代码来源:simulate.py

示例10: test_square_draw

def test_square_draw():
    """Test drawing squares without transforms using PolygonVisual"""
    pos = np.array([[-0.5, 0.5, 0],
                    [0.5, 0.5, 0],
                    [0.5, -0.5, 0],
                    [-0.5, -0.5, 0]])
    with TestingCanvas() as c:
        polygon = visuals.Polygon(pos=pos, color=(1, 0, 0, 1))
        polygon.transform = transforms.STTransform(scale=(50, 50),
                                                   translate=(50, 50))
        c.draw_visual(polygon)
        assert_image_equal("screenshot", 'visuals/square1.png')

        gloo.clear()
        polygon = visuals.Polygon(pos=pos, color=(1, 0, 0, 1),
                                  border_color=(1, 1, 1, 1))
        polygon.transform = transforms.STTransform(scale=(50, 50),
                                                   translate=(50, 50))
        c.draw_visual(polygon)
        assert_image_equal("screenshot", 'visuals/square2.png')

        gloo.clear()
        polygon = visuals.Polygon(pos=pos, border_color=(1, 1, 1, 1))
        polygon.transform = transforms.STTransform(scale=(50, 50),
                                                   translate=(50, 50))
        c.draw_visual(polygon)
        assert_image_equal("screenshot", 'visuals/square3.png', 0.45)
开发者ID:zhangweiabc,项目名称:vispy,代码行数:27,代码来源:test_polygon.py

示例11: on_draw

    def on_draw(self, event):
        while os.path.exists(self.filename()):
            self.frame += 1

        if self.frame > self.anim_frames:
            vispy.app.quit()

        print("{:5d}/{}".format(self.frame, self.anim_frames))
        self.fbo.activate()
        gloo.set_state(depth_test=False, clear_color='black')
        gloo.clear(color=True)
        w, h = self.fbsize
        gloo.set_viewport(0, 0, w, h)
        self.render['aspect'] = w / h
        self.render['width'] = w
        self.render['frame'] = self.frame
        self.render.draw('triangle_strip')
        self.context.finish()

        arr = self.fbo.read().copy()
        arr[:, :, 3] = 255
        img = Image.fromarray(arr)
        img.save(self.filename())

        self.frame += 1
        self.update()
开发者ID:kspi,项目名称:mapcat,代码行数:26,代码来源:mapcat_video.py

示例12: test_rectangle_draw

def test_rectangle_draw():
    """Test drawing rectangles with transforms using PolygonVisual"""
    pos = np.array([[-0.1, 0.5, 0],
                    [0.1, 0.5, 0],
                    [0.1, -0.5, 0],
                    [-0.1, -0.5, 0]])
    with TestingCanvas() as c:
        polygon = visuals.Polygon(pos=pos, color=(1, 1, 0, 1))
        polygon.transform = transforms.STTransform(scale=(200.0, 25),
                                                   translate=(50, 50))
        c.draw_visual(polygon)
        assert_image_equal("screenshot", 'visuals/rectangle1.png')

        gloo.clear()
        polygon = visuals.Polygon(pos=pos, color=(1, 1, 0, 1),
                                  border_color=(1, 0, 0, 1))
        polygon.transform = transforms.STTransform(scale=(200.0, 25),
                                                   translate=(50, 50))
        c.draw_visual(polygon)
        assert_image_equal("screenshot", 'visuals/rectangle2.png')

        gloo.clear()
        polygon = visuals.Polygon(pos=pos, border_color=(1, 0, 0, 1),
                                  border_width=2)
        polygon.transform = transforms.STTransform(scale=(200.0, 25),
                                                   translate=(50, 50))
        c.draw_visual(polygon)
        assert_image_equal("screenshot", 'visuals/rectangle3.png')
开发者ID:Peque,项目名称:vispy,代码行数:28,代码来源:test_polygon.py

示例13: test_use_framebuffer

def test_use_framebuffer():
    """Test drawing to a framebuffer"""
    shape = (100, 100)
    data = np.random.rand(*shape).astype(np.float32)
    orig_tex = Texture2D(data)
    use_shape = shape + (3,)
    fbo_tex = Texture2D(shape=use_shape, dtype=np.ubyte, format='rgb')
    rbo = ColorBuffer(shape=shape)
    fbo = FrameBuffer(color=fbo_tex)
    with Canvas(size=(100, 100)) as c:
        set_viewport((0, 0) + c.size)
        with fbo:
            draw_texture(orig_tex)
        draw_texture(fbo_tex)
        out_tex = _screenshot()[::-1, :, 0].astype(np.float32)
        assert_raises(TypeError, FrameBuffer.color_buffer.fset, fbo, 1.)
        assert_raises(TypeError, FrameBuffer.depth_buffer.fset, fbo, 1.)
        assert_raises(TypeError, FrameBuffer.stencil_buffer.fset, fbo, 1.)
        fbo.color_buffer = rbo
        fbo.depth_buffer = DepthBuffer(shape)
        fbo.stencil_buffer = None
        print((fbo.color_buffer, fbo.depth_buffer, fbo.stencil_buffer))
        clear(color='black')
        with fbo:
            clear(color='black')
            draw_texture(orig_tex)
            out_rbo = _screenshot()[:, :, 0].astype(np.float32)
    assert_allclose(data * 255., out_tex, atol=1)
    assert_allclose(data * 255., out_rbo, atol=1)
开发者ID:gbaty,项目名称:vispy,代码行数:29,代码来源:test_use_gloo.py

示例14: on_draw

    def on_draw(self, ev):
        test = self.physical_size
        gloo.set_viewport(800, 0, *self.physical_size)
        gloo.clear(color='white', depth=True)

        for mesh in self.meshes:
            mesh.draw()
开发者ID:esmam,项目名称:MRATPython27,代码行数:7,代码来源:Normalise.py

示例15: on_draw

    def on_draw(self, event):
      gloo.clear()

      self.program['u_light_position'] = [100., 100., 500.]
      self.program['u_is_lighting'] = True
      self.program['u_model'] = self.camera.model
      self.program['u_normal'] = self.camera.rotation 
      self.program['u_view'] = self.camera.view
      self.program['u_projection'] = self.camera.projection
      self.program['u_is_fog'] = self.camera.is_fog
      self.program['u_fog_far'] = self.camera.zoom + 50 
      self.program['u_fog_near'] = 1
      self.program['u_fog_color'] = self.camera.fog_color

      # self.program.bind(self.cylinder_vertex_buffer)
      # self.program.draw('triangles', self.cylinder_index_buffer)

      self.program.bind(self.arrow_buffer)
      self.program.draw('triangles')

      self.program.bind(self.ballstick_vertex_buffer)
      self.program.draw('triangles', self.ballstick_index_buffer)

      self.program.bind(self.cartoon_vertex_buffer)
      self.program.draw('triangles', self.cartoon_index_buffer)

      self.update()
开发者ID:otavitsch,项目名称:pyball,代码行数:27,代码来源:pyball.py


注:本文中的vispy.gloo.clear函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。