• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python gl.glColor4f函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: setupOpenGL

	def setupOpenGL(self):
		gl.glClearColor(0., 0., 0., 1.)
		gl.glColor4f(1.0, 0.0, 0.0, 0.5)
		gl.glEnable(gl.GL_DEPTH_TEST)
		#gl.glEnable(gl.GL_CULL_FACE)
		gl.glEnable(gl.GL_BLEND)
		gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
开发者ID:Tythos,项目名称:hypyr,代码行数:7,代码来源:main.py


示例2: draw_points

    def draw_points(self):
        self.points_lock.acquire()
        
        try:
            from pyglet.gl import glBegin, glEnd, GL_POINTS, glColor4f, glVertex2f
                   
            glBegin(GL_POINTS)
               
            for i in xrange(0, len(self.points)):
                p = self.points[i]
                parameter_index = self.parameter_indices[0]
                state_index = self.state_indices[0]

                glColor4f(1, 1, 1, p.age / (self.age_max*2.0))
                glVertex2f(p.parameters[parameter_index], p.state[state_index])
                
                p.state = self.system.iterate(p.state, p.parameters)
                p.age += 1
                
                #if p.age >= self.age_max:
                #    self.points[i] = OrbitPoint(tool=self, varying_parameter=p.parameters[parameter_index])
            
            glEnd()
        except Exception, detail:
            print 'draw_points()', type(detail), detail
开发者ID:cmorgan,项目名称:dypy,代码行数:25,代码来源:OrbitTool.py


示例3: draw_points

    def draw_points(self):
        self.points_lock.acquire()

        try:
            from pyglet.gl import glCallList, glBegin, GL_LINE_STRIP, glColor4f, glVertex2f, glEnd

            # line from previous iterate to next iterate of function
            glBegin(GL_LINE_STRIP)
            glColor4f(1, 1, 1, 0.3)

            state_index = self.state_indices[0]

            for i in [1, 2]:
                state_previous = self.point.state[state_index]
                self.point.state = self.system.iterate(self.point.state, self.point.parameters)

                glVertex2f(state_previous, state_previous)
                glVertex2f(state_previous, self.point.state[state_index])

            glEnd()

            # call display lists, doesn't work in init_points()
            if self.server.iteration <= 1:
                glCallList(self.iterate_list)
                glCallList(self.reflection_list)
        except Exception, detail:
            print "draw_points()", type(detail), detail
开发者ID:cmorgan,项目名称:dypy,代码行数:27,代码来源:CobwebTool.py


示例4: core_draw

    def core_draw(self):
        super(PointDisplayCanvas, self).core_draw()

        points, point_colors, linesegs, lineseg_colors = self.extra_points_linesegs
        gl.glColor4f(0.0, 1.0, 0.0, 1.0)  # green point

        if points is not None:
            if point_colors is None:
                point_colors = [(0, 1, 0, 1)] * len(points)
            gl.glBegin(gl.GL_POINTS)
            for color_4tuple, pt in zip(point_colors, points):
                gl.glColor4f(*color_4tuple)
                gl.glVertex2f(pt[0], pt[1])
            gl.glEnd()

        if linesegs is not None:
            if lineseg_colors is None:
                lineseg_colors = [(0, 1, 0, 1)] * len(linesegs)
            gl.glBegin(gl.GL_LINES)
            for color_4tuple, (x0, y0, x1, y1) in zip(lineseg_colors, linesegs):
                gl.glColor4f(*color_4tuple)
                gl.glVertex2f(x0, y0)
                gl.glVertex2f(x1, y1)
            gl.glEnd()

        if self.red_points is not None:
            gl.glColor4f(1.0, 0.0, 0.0, 1.0)
            gl.glBegin(gl.GL_POINTS)
            for pt in self.red_points:
                gl.glVertex2f(pt[0], pt[1])
            gl.glEnd()

        gl.glColor4f(1.0, 1.0, 1.0, 1.0)  # restore white color
开发者ID:BackupTheBerlios,项目名称:ctrax-svn,代码行数:33,代码来源:simple_overlay.py


示例5: draw_circle

def draw_circle(cx, cy, r, num_segments=None, mode=gl.GL_POLYGON, color=(1, 1, 1, 1)):
	if not num_segments:
		num_segments = get_num_circle_segments(r)

	theta = 2 * math.pi / float(num_segments)
	tangetial_factor = math.tan(theta)
	radial_factor = math.cos(theta)

	x = float(r)
	y = 0.0

	gl.glColor4f(color[0], color[1], color[2], color[3])
	gl.glBegin(mode)
	for i in xrange(num_segments):
		gl.glVertex2f(x + cx, y + cy)

		tx = y * -1
		ty = x

		x += tx * tangetial_factor
		y += ty * tangetial_factor

		x *= radial_factor
		y *= radial_factor
	gl.glEnd()
开发者ID:PermianLizard,项目名称:Pyweek-17,代码行数:25,代码来源:render.py


示例6: draw

    def draw(self):
        glPushMatrix()

        glTranslatef(self.xoffset, self.yoffset, self.zoffset)

        def color(i):
            if i % self.graduations_major == 0:
                glColor4f(*self.color_grads_major)
            elif i % (self.graduations_major / 2) == 0:
                glColor4f(*self.color_grads_interm)
            else:
                if self.light: return False
                glColor4f(*self.color_grads_minor)
            return True

        # draw the grid
        glBegin(GL_LINES)
        for i in range(0, int(math.ceil(self.width + 1))):
            if color(i):
                glVertex3f(float(i), 0.0, 0.0)
                glVertex3f(float(i), self.depth, 0.0)

        for i in range(0, int(math.ceil(self.depth + 1))):
            if color(i):
                glVertex3f(0, float(i), 0.0)
                glVertex3f(self.width, float(i), 0.0)
        glEnd()

        # draw fill
        glColor4f(*self.color_fill)
        glRectf(0.0, 0.0, float(self.width), float(self.depth))

        glPopMatrix()
开发者ID:Metamaquina,项目名称:Printrun,代码行数:33,代码来源:actors.py


示例7: core_draw

    def core_draw(self):
        super(PointDisplayCanvas, self).core_draw()

        points,point_colors, linesegs,lineseg_colors = self.extra_points_linesegs
        gl.glColor4f(0.0,1.0,0.0,1.0) # green point

        if points is not None:
            if point_colors is None:
                point_colors = [ (0,1,0,1) ] * len(points)
            gl.glBegin(gl.GL_POINTS)
            for color_4tuple,pt in zip(point_colors,points):
                gl.glColor4f(*color_4tuple)
                gl.glVertex2f(pt[0],pt[1])
            gl.glEnd()

        if linesegs is not None:
            if lineseg_colors is None:
                lineseg_colors = [ (0,1,0,1) ] * len(linesegs)
            for color_4tuple,this_lineseg in zip(lineseg_colors,linesegs):
                gl.glBegin(gl.GL_LINE_STRIP)
                gl.glColor4f(*color_4tuple)
                for (x,y) in zip(this_lineseg[0::2],this_lineseg[1::2]):
                    gl.glVertex2f(x,y)
                gl.glEnd()

        if self.red_points is not None:
            gl.glColor4f(1.0,0.0,0.0,0.5) # 50% alpha
            gl.glBegin(gl.GL_POINTS)
            for pt in self.red_points:
                gl.glVertex2f(pt[0],pt[1])
            gl.glEnd()

        gl.glColor4f(1.0,1.0,1.0,1.0) # restore white color
开发者ID:motmot,项目名称:wxglvideo,代码行数:33,代码来源:simple_overlay.py


示例8: rect

def rect(a, b, color=(1.0,1.0,1.0), alpha=1.0):
    """
    Draws a rectangle in the plane spanned by a,b with GL_QUADS

    :param a: Point a
    :type a: 2-float tuple

    :param b: Point b
    :type b: 2-float tuple

    :param color: the color in [0..1] range
    :type color: 3-float tuple

    :param aa: Anti aliasing Flag

    :param alpha: the alpha value in [0..1] range

    """

    glDisable(GL_TEXTURE_2D)

    glBegin(GL_QUADS)
    glVertex3f(a[0], a[1], 0)
    glVertex3f(b[0], a[1], 0)
    glVertex3f(b[0], b[1], 0)
    glVertex3f(a[0], b[1], 0)

    glEnd()
    glEnable(GL_TEXTURE_2D)
    glColor4f(color+(alpha,))
开发者ID:xoryouyou,项目名称:NetArgos,代码行数:30,代码来源:glutil.py


示例9: render_indicators

 def render_indicators(self, W, H):
     gl.glBegin(gl.GL_QUADS)
     s = W/40.0
     h = H/40.0
     gl.glColor4f(0,0,0,1)
     gl.glVertex3f(W, 0, 0)
     gl.glVertex3f(W, 5*h, 0)
     gl.glVertex3f(0, 5*h, 0)
     gl.glVertex3f(0, 0, 0)
     def vertical_ind(place, val, color):
         gl.glColor4f(color[0], color[1], color[2], 1)
         gl.glVertex3f((place+0)*s, h + h*val, 0)
         gl.glVertex3f((place+1)*s, h + h*val, 0)
         gl.glVertex3f((place+1)*s, h, 0)
         gl.glVertex3f((place+0)*s, h, 0)
     def horiz_ind(place, val, color):
         gl.glColor4f(color[0], color[1], color[2], 1)
         gl.glVertex3f((place+0)*s, 4*h , 0)
         gl.glVertex3f((place+val)*s, 4*h, 0)
         gl.glVertex3f((place+val)*s, 2*h, 0)
         gl.glVertex3f((place+0)*s, 2*h, 0)
     true_speed = np.sqrt(np.square(self.car.hull.linearVelocity[0]) + np.square(self.car.hull.linearVelocity[1]))
     vertical_ind(5, 0.02*true_speed, (1,1,1))
     vertical_ind(7, 0.01*self.car.wheels[0].omega, (0.0,0,1)) # ABS sensors
     vertical_ind(8, 0.01*self.car.wheels[1].omega, (0.0,0,1))
     vertical_ind(9, 0.01*self.car.wheels[2].omega, (0.2,0,1))
     vertical_ind(10,0.01*self.car.wheels[3].omega, (0.2,0,1))
     horiz_ind(20, -10.0*self.car.wheels[0].joint.angle, (0,1,0))
     horiz_ind(30, -0.8*self.car.hull.angularVelocity, (1,0,0))
     gl.glEnd()
     self.score_label.text = "%04i" % self.reward
     self.score_label.draw()
开发者ID:jiapei100,项目名称:gym,代码行数:32,代码来源:car_racing.py


示例10: draw

    def draw(self):
        from miru.context import context
        gl.glEnable(gl.GL_LINE_STIPPLE)
        gl.glLineStipple(1, 0x51315)
        gl.glColor4f(*self.color)
        for c in self.metaCamera.cameras:

            vp = c.projection

            x = vp.x == 0 and 1 or vp.x
            width = vp.x == 0 and vp.width - 1 or vp.width
            width = (vp.x + vp.width) >= context.window.width and width - 1 or width

            y = vp.y == 0 and 1 or vp.y
            height = vp.y == 0 and vp.height - 1 or vp.height
            height = (vp.y + vp.height) >= context.window.height and height - 1 or height

            gl.glBegin(gl.GL_LINE_LOOP)
            gl.glVertex2f(x, y)
            gl.glVertex2f(x, y + height)
            gl.glVertex2f(x + width, y + height)
            gl.glVertex2f(x + width, y)
            gl.glEnd()
        gl.glDisable(gl.GL_LINE_LOOP)
        gl.glColor4f(1,1,1,1)
开发者ID:Knio,项目名称:miru,代码行数:25,代码来源:camera.py


示例11: circle

def circle(pos, radius, color=(1.0,1.0,1.0), alpha=1.0,segments=6):
    """
    Draws a circle with gluDisk 
    
    :param pos: center of the circle
    :type pos: 2-float tuple

    :param radius: radius of the circle
    :type radius: float

    :param color: the color in [0..1] range
    :type color: 3-float tuple

    :param alpha: the alpha value in [0..1] range

    :param segments: number of segments
    :type segments: int

    """

    glDisable(GL_TEXTURE_2D)

    c = gluNewQuadric()
    glColor4f(color[0], color[1], color[2], alpha)
    glPushMatrix()
    glTranslatef(pos[0], pos[1], 0)
    gluDisk(c, 0, radius, segments, 1)
    glPopMatrix()
    glColor4f(1.0,1.0,1.0,1.0)
    glEnable(GL_TEXTURE_2D)
开发者ID:xoryouyou,项目名称:NetArgos,代码行数:30,代码来源:pool.py


示例12: draw

    def draw(self, frame):
        # The gneneral plan here is:
        #  1. Get the dots in the range of 0-255.
        #  2. Create a texture with the dots data.
        #  3. Draw the texture, scaled up with nearest-neighbor.
        #  4. Draw a mask over the dots to give them a slightly more realistic look.

        gl.glEnable(gl.GL_BLEND)
        gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
        gl.glLoadIdentity()

        # Draw the dots in this color:
        #gl.glColor3f(1.0, 0.5, 0.25)

        gl.glScalef(1, -1, 1)
        gl.glTranslatef(0, -DMD_SIZE[1]*DMD_SCALE, 0)

        #data = frame.get_data_mult()
        
        #this new jk_get_data will read the dots using the dmd function
        #and convert them via the map to rGB.
        data = self.jk_get_data(frame)

        image = pyglet.image.ImageData(DMD_SIZE[0], DMD_SIZE[1], 'RGB', data, pitch=DMD_SIZE[0] * 3)  

        gl.glTexParameteri(image.get_texture().target, gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST)
        image.blit(0, 0, width=DMD_SIZE[0]*DMD_SCALE, height=DMD_SIZE[1]*DMD_SCALE)

        del image

        gl.glScalef(DMD_SCALE/float(MASK_SIZE), DMD_SCALE/float(MASK_SIZE), 1.0)
        gl.glColor4f(1.0, 1.0, 1.0, 1.0)
        self.mask_texture.blit_tiled(x=0, y=0, z=0, width=DMD_SIZE[0]*MASK_SIZE, height=DMD_SIZE[1]*MASK_SIZE)
开发者ID:horseyhorsey,项目名称:SkeletonProcVisualPinball10,代码行数:33,代码来源:desktop_pyglet.py


示例13: line

def line(a, b, color=(1.0,1.0,1.0), width=1, aa=False, alpha=1.0):
    """
    Draws a line from point *a* to point *b* using GL_LINE_STRIP optionaly with GL_LINE_SMOOTH when *aa=True*

    :param a: Point a
    :type a: 2-float tuple

    :param b: Point b
    :type b: 2-float tuple

    :param color: the color in [0..1] range
    :type color: 3-float tuple

    :param width: The with for glLineWidth()

    :param aa: Anti aliasing Flag

    :param alpha: the alpha value in [0..1] range

    """
    glColor4f(color[0], color[1], color[2], alpha)

    glLineWidth(width)
    if aa:
        glEnable(GL_LINE_SMOOTH)

    draw(2, GL_LINES, ('v2f', (a[0], a[1], b[0], b[1])))
开发者ID:xoryouyou,项目名称:NetArgos,代码行数:27,代码来源:glutil.py


示例14: _draw_rects

def _draw_rects(shape_list, vertex_vbo_id, texture_coord_vbo_id):
    """
    Draw a set of rectangles using vertex buffers. This is more efficient
    than drawing them individually.
    """
    GL.glEnable(GL.GL_BLEND)
    GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)
    GL.glEnable(GL.GL_TEXTURE_2D)
    GL.glHint(GL.GL_POLYGON_SMOOTH_HINT, GL.GL_NICEST)
    GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST)

    # GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)
    # GL.glMatrixMode(GL.GL_MODELVIEW)
    # GL.glDisable(GL.GL_BLEND)

    GL.glBindBuffer(GL.GL_ARRAY_BUFFER, vertex_vbo_id)
    GL.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY)
    GL.glEnableClientState(GL.GL_VERTEX_ARRAY)
    GL.glVertexPointer(2, GL.GL_FLOAT, 0, 0)

    GL.glBindBuffer(GL.GL_ARRAY_BUFFER, texture_coord_vbo_id)

    offset = 0
    for shape in shape_list:
        if shape.can_cache:
            texture_coord_vbo_id = None

            GL.glColor4f(1, 1, 1, shape.alpha)

            _render_rect_filled(shape, offset,
                                shape.texture.texture_id, texture_coord_vbo_id)

            offset += 4
        else:
            shape.draw()
开发者ID:pauleveritt,项目名称:arcade,代码行数:35,代码来源:sprite.py


示例15: rectangle

def rectangle(x1, y1, x2, y2, color=(1, 0, 0, 1)):
    glColor4f(*color)
    glBegin(GL_POLYGON)
    glVertex2f(x1, y1)
    glVertex2f(x1, y2)
    glVertex2f(x2, y2)
    glVertex2f(x2, y1)
    glEnd()
开发者ID:evuez,项目名称:raycaster,代码行数:8,代码来源:geometry.py


示例16: set_state

 def set_state(self):
     gl.glPushAttrib(gl.GL_LINE_BIT | gl.GL_CURRENT_BIT)
     gl.glLineWidth(2)
     if self.facet.is_border_facet:
         colour = self.BORDER_FACET_COLOUR
     else:
         colour = self.INNER_FACET_COLOUR
     gl.glColor4f(*colour)
开发者ID:weltenwort,项目名称:uni_mt,代码行数:8,代码来源:facets.py


示例17: draw

 def draw(self, offset=(0, 0)):
     w, h = offset
     r, g, b, a = self.color
     pyglet.graphics.draw(len(self.vertices), gl.GL_POLYGON,
         ('v2f', [int(p) for p in flatten((x+w, y+h) for x, y in self.vertices)]),
         ('c4B', [int(c) for c in ((r, g, b, a*255) * len(self.vertices))]),
     )
     gl.glColor4f(1, 1, 1, 1)
开发者ID:alex,项目名称:evolves,代码行数:8,代码来源:evolves.py


示例18: draw

 def draw(self):
     glPushMatrix()
     glRotatef(self.angle, 0., 0., 1.)
     glScalef(self.scale, 1., 1.)
     glTranslatef(0., -common_res.ray.height/2, 0.)
     glColor4f(1., 1., 1., self.alpha)
     common_res.ray.blit(0, 0)
     glPopMatrix()
开发者ID:AojiaoZero,项目名称:thbattle,代码行数:8,代码来源:game_controls.py


示例19: draw_grid

 def draw_grid(self):
     gl.glColor4f(0.23, 0.23, 0.23, 1.0)
     #Horizontal lines
     for i in range(rows):
         graphics.draw(2, gl.GL_LINES, ('v2i', (0, i * cell_size, window_width, i * cell_size)))
     #Vertical lines
     for j in range(columns):
         graphics.draw(2, gl.GL_LINES, ('v2i', (j * cell_size, 0, j * cell_size, window_height)))
开发者ID:fdfalcon,项目名称:pyglet-turmite,代码行数:8,代码来源:pyglet-turmite.py


示例20: draw

 def draw(self):
     if not self.should_draw: return
     glColor3f(1, 1, 1)
     self.texture.blit(0, 100)
     glColor4f(1, 1, 1, 0.65)
     glRectf(0, 0, self.width, 100)
     self.lbls.draw()
     self.draw_subcontrols()
开发者ID:feisuzhu,项目名称:thbattle,代码行数:8,代码来源:inputs.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python gl.glColor4ub函数代码示例发布时间:2022-05-25
下一篇:
Python gl.glColor3f函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap