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


Python gloo.set_clear_color函数代码示例

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


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

示例1: __init__

    def __init__(self, emulate3d=True):
        app.Canvas.__init__(self, keys='interactive', size=((W*5), (H*5)))

        if emulate3d:
            tex_cls = gloo.TextureEmulated3D
        else:
            tex_cls = gloo.Texture3D
        self.texture = tex_cls(img_array, interpolation='nearest',
                               wrapping='clamp_to_edge')

        self.program = ModularProgram(VERT_SHADER, FRAG_SHADER)
        self.program.frag['sampler_type'] = self.texture.glsl_sampler_type
        self.program.frag['sample'] = self.texture.glsl_sample
        self.program['u_texture'] = self.texture
        self.program['i'] = 0.0
        self.program.bind(gloo.VertexBuffer(data))

        self.view = np.eye(4, dtype=np.float32)
        self.model = np.eye(4, dtype=np.float32)
        self.projection = np.eye(4, dtype=np.float32)

        self.program['u_model'] = self.model
        self.program['u_view'] = self.view
        self.projection = ortho(0, W, 0, H, -1, 1)
        self.program['u_projection'] = self.projection

        self.i = 0

        gloo.set_clear_color('white')

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

        self.show()
开发者ID:Eric89GXL,项目名称:vispy,代码行数:33,代码来源:animate_images_slice.py

示例2: __init__

    def __init__(self):
        app.Canvas.__init__(self, keys='interactive', size=((W * 5), (H * 5)))

        self.program = gloo.Program(VERT_SHADER, FRAG_SHADER)
        self.texture = gloo.Texture2D(I, interpolation='linear')

        self.program['u_texture'] = self.texture
        self.program.bind(gloo.VertexBuffer(data))

        self.view = np.eye(4, dtype=np.float32)
        self.model = np.eye(4, dtype=np.float32)
        self.projection = np.eye(4, dtype=np.float32)

        self.program['u_model'] = self.model
        self.program['u_view'] = self.view
        self.projection = ortho(0, W, 0, H, -1, 1)
        self.program['u_projection'] = self.projection

        gloo.set_clear_color('white')

        self._timer = app.Timer('auto', connect=self.update, start=True)

        self.sim_is_initialized = False
        self.sim = None

        self.show()
开发者ID:btweinstein,项目名称:2d-lb,代码行数:26,代码来源:interop_test.py

示例3: __init__

    def __init__(self, *args, **kwargs):
        app.Canvas.__init__(self, *args, **kwargs)
        self.program = gloo.Program(self.read_shader('1.vert'), self.read_shader('3.frag'))

        # Fill screen with single quad, fragment shader does all the real work
        self.program["position"] = [(-1, -1), (-1, 1), (1, 1),
                                    (-1, -1), (1, 1), (1, -1)]

        self._starttime = time.time()
        self.program['time'] = 0

        self.program['cameraPos'] = (0.0, 3.0, -6.0)
        self.program['cameraLookat'] = (0.0, -0.85, 0.5)
        self.program['lightDir'] = normalize(np.array((-1, -1, -1)))  # needs to be normalized
        self.program['lightColour'] = (1.4, 3.0, 0.3)
        self.program['diffuse'] = (0.27, 0.27, 0.27)
        self.program['ambientFactor'] = 0.45
        self.program['rotateWorld'] = True
        self.program['scale'] = 1.5
        self.program['offset'] = 1.8
        self.program['cubeWidth'] = 1
        self.program['angleA'] = 1
        self.program['angleB'] = 1

        self.apply_zoom()

        gloo.set_clear_color(color='black')
        self._timer = app.Timer('auto', connect=self.update, start=True)
        self.show()
开发者ID:airhorns,项目名称:body-fractals,代码行数:29,代码来源:3.py

示例4: __init__

    def __init__(self, *args, **kwargs):
        app.Canvas.__init__(self, *args, **kwargs)
        self.program = gloo.Program(self.read_shader('1.vert'), self.read_shader('1.frag'))

        # Fill screen with single quad, fragment shader does all the real work
        self.program["position"] = [(-1, -1), (-1, 1), (1, 1),
                                    (-1, -1), (1, 1), (1, -1)]

        self._starttime = time.time()
        self.program['time'] = 0

        self.program['cameraPos'] = (0.0, 3.0, -6.0)
        self.program['cameraLookat'] = (0.0, -0.85, 0.5)
        self.program['lightDir'] = (-1.4, 0.8, -1.0)  # needs to be normalized
        self.program['lightColour'] = (3.0, 1.4, 0.3)
        self.program['diffuse'] = (0.3, 0.3, 0.3)
        self.program['ambientFactor'] = 0.35
        self.program['rotateWorld'] = 1
        # self.program['ao'] = True
        # self.program['shadows'] = True
        # self.program['antialias'] = False  # mutually exclusive with dof

        self.apply_zoom()

        gloo.set_clear_color(color='black')
        self._timer = app.Timer('auto', connect=self.update, start=True)
        self.show()
开发者ID:airhorns,项目名称:body-fractals,代码行数:27,代码来源:1.py

示例5: __init__

    def __init__(self):
        app.Canvas.__init__(self, size=(1024, 1024), title='Skybox example',
                            keys='interactive')

        self.cubeSize = 10
        self.pressed = False
        self.azimuth = pi / 2.0
        self.elevation = pi / 2.0
        self.distanceMin = 1
        self.distanceMax = 50
        self.distance = 30
        self.sensitivity = 5.0
        self.view = getView(self.azimuth, self.elevation, self.distance)
        self.model = np.eye(4, dtype=np.float32)
        self.projection = np.eye(4, dtype=np.float32)

        self.program = gloo.Program(vertex_shader, fragment_shader, count=24)
        self.program['a_position'] = faces*self.cubeSize
        self.program['a_texcoord'] = faces
        self.program['a_texture'] = gloo.TextureCube(texture, interpolation='linear')
        self.program['u_model'] = self.model
        self.program['u_view'] = self.view
        gloo.set_viewport(0, 0, *self.physical_size)
        self.projection = perspective(60.0, self.size[0] /
                                      float(self.size[1]), 1.0, 100.0)
        self.program['u_projection'] = self.projection

        gl.glEnable(gl.GL_DEPTH_TEST)
        gloo.set_clear_color('black')
        self.show()
开发者ID:vispy,项目名称:vispy,代码行数:30,代码来源:skybox.py

示例6: __init__

    def __init__(self):
        app.Canvas.__init__(self, keys='interactive')
        self.size = 800, 600

        self.vertices, self.filled, self.outline = cube()
        self.filled_buf = gloo.IndexBuffer(self.filled)
        self.outline_buf = gloo.IndexBuffer(self.outline)

        self.program = gloo.Program(vert, frag)
        self.program.bind(gloo.VertexBuffer(self.vertices))

        self.view = np.eye(4, dtype=np.float32)
        self.model = np.eye(4, dtype=np.float32)
        self.projection = np.eye(4, dtype=np.float32)

        translate(self.view, 0, 0, -5)
        self.program['u_model'] = self.model
        self.program['u_view'] = self.view

        self.theta = 0
        self.phi = 0

        gloo.set_clear_color('white')
        gloo.set_state('opaque')
        gloo.set_polygon_offset(1, 1)

        self._timer = app.Timer('auto', connect=self.on_timer, start=True)
开发者ID:almarklein,项目名称:vispy,代码行数:27,代码来源:rotate_cube.py

示例7: __init__

    def __init__(self, parent=None):
        scene.SceneCanvas.__init__(self, parent=parent)

        self.parent = parent
        self.has_redrawn = True

        self.data = None
        self.program = gloo.Program(vert, frag)

        self.colormap = ColorMap('colormaps/transform/Seismic.ppm')

        self.program_cm = gloo.Program(cm_vert, cm_frag)
        #self.
        
        self.line_type = None
        self.line_coord = 0
        self.line_positions = [(0, 0), (0, 0)]

        self.program_line = gloo.Program(basic_vert, basic_frag)
        self.program_line['a_position'] = self.line_positions

        gloo.set_clear_color((1, 1, 1, 1))

        canvas_size = (1000, 800)
        graph_size = (900, 700)
        margin_x = (canvas_size[0]-graph_size[0]) / 2.
        margin_y = (canvas_size[1]-graph_size[1]) / 2.
        pos_xax = np.array([[margin_x, canvas_size[1]-margin_y],
                   [canvas_size[0]-margin_x, canvas_size[1]-margin_y]])
        self.axis_x = AxisVisual(pos_xax, (0, 100), (0., 1.))
        self.tr_sys = visuals.transforms.TransformSystem(self)
开发者ID:majacassidy,项目名称:qtplot,代码行数:31,代码来源:canvas.py

示例8: __init__

    def __init__(self,):
        app.Canvas.__init__(self)
        self.size = 800, 600
        # fovy, zfar params
        self.fovy = 45.0
        self.zfar = 10.0
        width, height = self.size
        self.aspect = width / float(height)

        self.program = gloo.Program(vert, frag)

        self.view = np.eye(4, dtype=np.float32)
        self.model = np.eye(4, dtype=np.float32)
        self.projection = np.eye(4, dtype=np.float32)
        translate(self.view, 0, 0, -5.0)

        self.program['u_model'] = self.model
        self.program['u_view'] = self.view

        self.theta = 0
        self.phi = 0
        self.visible = True

        self._timer = app.Timer(1.0 / 60)
        self._timer.connect(self.on_timer)
        self._timer.start()

    # ---------------------------------
        gloo.set_clear_color((1, 1, 1, 1))
        gloo.set_state('opaque')
        gloo.set_polygon_offset(1, 1)
开发者ID:ajgappmark,项目名称:vispy,代码行数:31,代码来源:primitive_mesh_viewer_qt.py

示例9: __init__

    def __init__(self):
        app.Canvas.__init__(self, keys='interactive', size=(800, 600))

        self.vertices, self.filled, self.outline = cube()
        self.filled_buf = gloo.IndexBuffer(self.filled)
        self.outline_buf = gloo.IndexBuffer(self.outline)

        self.program = gloo.Program(vert, frag)
        self.program.bind(gloo.VertexBuffer(self.vertices))

        self.view = translate((0, 0, -5))
        self.model = np.eye(4, dtype=np.float32)

        gloo.set_viewport(0, 0, self.physical_size[0], self.physical_size[1])
        self.projection = perspective(45.0, self.size[0] /
                                      float(self.size[1]), 2.0, 10.0)

        self.program['u_projection'] = self.projection

        self.program['u_model'] = self.model
        self.program['u_view'] = self.view

        self.theta = 0
        self.phi = 0

        gloo.set_clear_color('white')
        gloo.set_state('opaque')
        gloo.set_polygon_offset(1, 1)

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

        self.show()
开发者ID:Calvarez20,项目名称:vispy,代码行数:32,代码来源:rotate_cube.py

示例10: draw_distortion

    def draw_distortion(self, *Contexts):
        '''Distorter.draw(list_of_drawables)
        Draw the drawables to the right and left-eye render buffers,
        then apply the distortion and display these buffers to the screen
        TODO:
        How can we globally handle view?
        Should we even bother trying to find the 'right' way to do this?
        '''
        gloo.set_clear_color('black')
        gloo.set_state(depth_test=True)

        with self.left_eye:
            gloo.clear(color=True, depth=True)
            for context in Contexts:
                context.translate(0, self.IPD / 2, 0)
                context.set_projection(self.L_projection)
                context.draw()

        with self.right_eye:
            gloo.clear(color=True, depth=True)
            for context in Contexts:
                context.translate(0, -self.IPD / 2, 0)
                context.set_projection(self.R_projection)
                context.draw()

        gloo.clear(color=True, depth=True)
        self.left_eye_program.draw('triangles', self.left_eye_indices)
        self.right_eye_program.draw('triangles', self.right_eye_indices)
开发者ID:jpanikulam,项目名称:visar,代码行数:28,代码来源:make_distortion.py

示例11: __init__

    def __init__(self):
        app.Canvas.__init__(self, keys='interactive')
        self.size = W * 5, H * 5

        self.program = gloo.Program(VERT_SHADER, FRAG_SHADER)
        self.texture = gloo.Texture3D(I, interpolation='nearest',
                                      wrapping='clamp_to_edge')
        self.program['u_texture'] = self.texture
        self.program['i'] = 0.0
        self.program.bind(gloo.VertexBuffer(data))

        self.view = np.eye(4, dtype=np.float32)
        self.model = np.eye(4, dtype=np.float32)
        self.projection = np.eye(4, dtype=np.float32)

        self.program['u_model'] = self.model
        self.program['u_view'] = self.view
        self.projection = ortho(0, W, 0, H, -1, 1)
        self.program['u_projection'] = self.projection

        self.i = 0

        gloo.set_clear_color('white')

        self._timer = app.Timer('auto', connect=self.on_timer, start=True)
开发者ID:almarklein,项目名称:vispy,代码行数:25,代码来源:animate_images_slice.py

示例12: __init__

    def __init__(self, **kwargs):
        app.Canvas.__init__(self, **kwargs)
        self.geometry = 0, 0, 400, 400
        
        mesh = create_sphere(10, 10, radius=2.)
        vertices = mesh.get_vertices()
        tris = mesh.get_faces()
        data=vertices[:, 2]
        self.filled_buf = gloo.IndexBuffer(tris)      

        self.program = ModularProgram(VERT_CODE, FRAG_CODE)
        colormap = get_colormap('autumn')
        self.color = Function(colormap.glsl_map)
        self.program.frag['color'] = self.color('floor(v_value*10.+0.5)/10.')  

        # Set attributes
        self.program['a_position'] = gloo.VertexBuffer(vertices)
        self.program['a_value'] = gloo.VertexBuffer(normalize(data, data.min(), data.max()))

        # Handle transformations
        self.init_transforms()
        
        

        gloo.set_clear_color((1, 1, 1, 1))
        gloo.set_state(depth_test=True)

        self._timer = app.Timer('auto', connect=self.update_transforms)
        self._timer.start()
开发者ID:ydanilin,项目名称:MinecraftMinerals,代码行数:29,代码来源:test_glsl_banded_sphere.py

示例13: __init__

    def __init__(self):
        app.Canvas.__init__(self, title='Rain [Move mouse]',
                            size=(512, 512), keys='interactive')

        # Build data
        # --------------------------------------
        n = 500
        self.data = np.zeros(n, [('a_position', np.float32, 2),
                                 ('a_fg_color', np.float32, 4),
                                 ('a_size',     np.float32, 1)])
        self.index = 0
        self.program = Program(vertex, fragment)
        self.vdata = VertexBuffer(self.data)
        self.program.bind(self.vdata)
        self.program['u_antialias'] = 1.00
        self.program['u_linewidth'] = 1.00
        self.program['u_model'] = np.eye(4, dtype=np.float32)
        self.program['u_view'] = np.eye(4, dtype=np.float32)

        self.activate_zoom()

        gloo.set_clear_color('white')
        gloo.set_state(blend=True,
                       blend_func=('src_alpha', 'one_minus_src_alpha'))
        self.timer = app.Timer('auto', self.on_timer, start=True)

        self.show()
开发者ID:Eric89GXL,项目名称:vispy,代码行数:27,代码来源:rain.py

示例14: __init__

    def __init__(self, parent=None):
        scene.SceneCanvas.__init__(self, parent=parent)

        self.parent = parent
        self.has_redrawn = True

        self.data = None
        self.data_changed = False
        self.data_program = gloo.Program(data_vert, data_frag)

        path = os.path.dirname(os.path.realpath(__file__))
        path = os.path.join(path, 'colormaps/transform/Seismic.npy')
        self.colormap = Colormap(path)

        self.colormap_program = gloo.Program(colormap_vert, colormap_frag)

        #  horizontal / vertical / diagonal
        self.line_type = None
        # x for a vertical line, y for a horizontal line
        self.line_coord = None
        # start and end points
        self.line_positions = [(0, 0), (0, 0)]

        self.linecut_program = gloo.Program(linecut_vert, linecut_frag)
        self.linecut_program['a_position'] = self.line_positions

        gloo.set_clear_color((1, 1, 1, 1))
开发者ID:dbouman1,项目名称:qtplot,代码行数:27,代码来源:canvas.py

示例15: __init__

    def __init__(self,controller, **kwargs):
        app.Canvas.__init__(self, **kwargs)
        self._controller = controller
        self.geometry = 0, 0, 400, 400

        self.program = gloo.Program("shaders/raytracingalgo.vertexshader", "shaders/raytracingalgo.fragmentshader")

        self.program['a_position'] = [(-1., -1.), (-1., +1.),(+1., -1.), (+1., +1.)]
        self.program['sphere_position_0'] = (.75, .1, 1.)
        self.program['sphere_radius_0'] = .6
        self.program['sphere_color_0'] = (1., 1., 1.)
        self.program['sphere_position_1'] = (-.75, .1, 2.25)
        self.program['sphere_radius_1'] = .6
        self.program['sphere_color_1'] = (1., 1., 1.)
        self.program['plane_position'] = (0., -.5, 0.)
        self.program['plane_normal'] = (0., 1., 0.)
        self.program['light_intensity'] = 1.
        self.program['light_specular'] = (1., 50.)
        self.program['light_position'] = (5., 5., -10.)
        self.program['light_color'] = (1., 1., 1.)
        self.program['ambient'] = .05
        self.program['O'] = (0., 0., -1.)

        gloo.set_clear_color((1, 1, 1, 1))
        gloo.set_state(depth_test=True)

        #self.program.draw('triangle_strip')

        #self.active = True
        self._timer = app.Timer('auto', connect=self.timedUpdate, start=True)

        self._fps = 1
        self._timerfps = 24
        self._softFPS = []
开发者ID:PierreGe,项目名称:ba3-project,代码行数:34,代码来源:RayTracingWidget.py


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