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


Python gl.glColor4ub函数代码示例

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


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

示例1: on_draw

    def on_draw(self):
        self.parent.set_caption(str(pyglet.clock.get_fps()))
        gl.glClear(gl.GL_COLOR_BUFFER_BIT)
        gl.glColor4ub(*[255,255,255,255])
        self.room.bg.blit(0,0)

        self.room.render()
        
        gl.glColor4ub(255,255,255,255)
        self.player.draw()
        self.room.lightbatch.draw()
        self.player.draw_eye()
        self.player.draw_integrity()
        
        if self.pause:
            gl.glColor4ub(50,50,50,150)
            left = self.message['text'].x-self.message['text'].width/2 -5
            down = self.message['text'].y-self.message['text'].height/2 -5
            right = self.message['text'].x+self.message['text'].width/2 + 5
            up = self.message['text'].y+self.message['text'].height/2 + 5
            gl.glRecti(left,down,right,up)
            gl.glLineWidth(2)
            gl.glColor4ub(200,200,200,200)
            gl.glBegin(gl.GL_LINE_LOOP)
            gl.glVertex2i(left,down)
            gl.glVertex2i(left,up)
            gl.glVertex2i(right,up)
            gl.glVertex2i(right,down)
            gl.glEnd()
            gl.glLineWidth(1)
            gl.glColor4ub(255,255,255,255)
            self.message['text'].draw()
            self.message['helper'].draw()
            self.message['sprite'].draw()
开发者ID:Hugoagogo,项目名称:Alison-in-Wonderland,代码行数:34,代码来源:main.py

示例2: draw_bounding_box

    def draw_bounding_box(self, x, y, screen_height):
        bb = self.get_bounding_box()
        bb = [bb['min_x'], bb['min_y'], bb['max_x'], bb['max_y']]
        vertices = ()
        for _ in bb:
            vertices += (_.x,)
            vertices += (screen_height - _.y,)

        # get opengl vertices of type GLfloat
        vertices_gl = (GLfloat * len(vertices))(*vertices)

        # set the color
        glColor4ub(0, 255, 0, 255);
        glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );

        # turn on blend for alpha channel
        glEnable(GL_BLEND)

        # tell open GL were passing a vertex array
        glEnableClientState(GL_VERTEX_ARRAY)

        # create a pointer to vertices_gl
        glVertexPointer(2, GL_FLOAT, 0, vertices_gl)
       
        # draw the array
        glDrawArrays(GL_POLYGON, 0, len(vertices) // 2)

        glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
开发者ID:bm1362,项目名称:atlas-py,代码行数:28,代码来源:RigidBody.py

示例3: draw_button

    def draw_button(self, x, y, point_down, over):
        if over and self.pressed:
            border = SCROLL_BAR_PRESSED
        elif over:
            border = SCROLL_BAR_OVER
        else:
            border = SCROLL_BAR_BORDER
        draw_rectangle(x, y, x + self.width, y + self.buttonHeight, 
            border)
        draw_rectangle(x + 1, y + 1, x + self.width - 1, 
            y + self.buttonHeight - 1, SCROLL_BAR_BUTTON)
        glBegin(GL_TRIANGLES)
        glColor4ub(*SCROLL_BAR_POINTER)
        singleX = self.width / 3.0
        upperX = self.width / 2.0
        singleY = self.buttonHeight / 3.0
        if point_down:
            y -= 1
            glVertex2f(singleX + x, singleY * 2 + y)
            glVertex2f(upperX + x, singleY + y)
            glVertex2f(singleX * 2 + x, singleY * 2 + y)

        else:
            glVertex2f(singleX + x, singleY + y)
            glVertex2f(upperX + x, singleY * 2 + y)
            glVertex2f(singleX * 2 + x, singleY + y)
        glEnd()
开发者ID:Matt-Esch,项目名称:anaconda,代码行数:27,代码来源:gui.py

示例4: on_draw

    def on_draw(self):
        """
        Render the screen.
        """
        start = time.time()

        float_size = ctypes.sizeof(ctypes.c_float)
        record_len = 10 * float_size

        GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)

        GL.glMatrixMode(GL.GL_MODELVIEW)
        GL.glEnableClientState(GL.GL_VERTEX_ARRAY)

        GL.glColor4ub(255, 0, 0, 255)

        GL.glBindBuffer(GL.GL_ARRAY_BUFFER, self.rect_vbo.vbo_id)
        GL.glVertexPointer(2, GL.GL_FLOAT, record_len, 0)

        for i in range(len(self.shape_list)):
            shape = self.shape_list[i]
            GL.glLoadIdentity()
            GL.glTranslatef(shape.x, shape.y, 0)
            GL.glDrawArrays(GL.GL_QUADS, i * 8, 8)
        # GL.glDrawArrays(GL.GL_QUADS,
        #           0,
        #           self.rect_vbo.size)

        elapsed = time.time() - start
        print(elapsed)
开发者ID:apalm112,项目名称:arcade,代码行数:30,代码来源:a_quick_test5.py

示例5: draw_rectangle

def draw_rectangle(x1, y1, x2, y2, r, g, b):
    gl.glColor4ub(r, g, b, 255)
    gl.glBegin(gl.GL_QUADS)
    gl.glVertex2f(x1, y1)
    gl.glVertex2f(x2, y1)
    gl.glVertex2f(x2, y2)
    gl.glVertex2f(x1, y2)
    gl.glEnd()
开发者ID:Matt-Esch,项目名称:anaconda,代码行数:8,代码来源:question.py

示例6: draw_rectangle_outline

def draw_rectangle_outline(center_x, center_y, width, height, color,
                           border_width=1, tilt_angle=0):
    """
    Draw a rectangle outline.

    Args:
        :x: x coordinate of top left rectangle point.
        :y: y coordinate of top left rectangle point.
        :width: width of the rectangle.
        :height: height of the rectangle.
        :color: color, specified in a list of 3 or 4 bytes in RGB or
         RGBA format.
        :border_width: width of the lines, in pixels.
        :angle: rotation of the rectangle. Defaults to zero.
    Returns:
        None
    Raises:
        None

    Example:

    >>> import arcade
    >>> arcade.open_window("Drawing Example", 800, 600)
    >>> arcade.set_background_color(arcade.color.WHITE)
    >>> arcade.start_render()
    >>> arcade.draw_rectangle_outline(278, 150, 45, 105, \
arcade.color.BRITISH_RACING_GREEN, 2)
    >>> arcade.finish_render()
    >>> arcade.quick_run(0.25)
    """

    GL.glEnable(GL.GL_BLEND)
    GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)
    GL.glEnable(GL.GL_LINE_SMOOTH)
    GL.glHint(GL.GL_LINE_SMOOTH_HINT, GL.GL_NICEST)
    GL.glHint(GL.GL_POLYGON_SMOOTH_HINT, GL.GL_NICEST)

    GL.glLoadIdentity()
    GL.glTranslatef(center_x, center_y, 0)
    if tilt_angle:
        GL.glRotatef(tilt_angle, 0, 0, 1)

    # Set line width
    GL.glLineWidth(border_width)

    # Set color
    if len(color) == 4:
        GL.glColor4ub(color[0], color[1], color[2], color[3])
    elif len(color) == 3:
        GL.glColor4ub(color[0], color[1], color[2], 255)

    GL.glBegin(GL.GL_LINE_LOOP)
    GL.glVertex3f(-width // 2, -height // 2, 0.5)
    GL.glVertex3f(width // 2, -height // 2, 0.5)
    GL.glVertex3f(width // 2, height // 2, 0.5)
    GL.glVertex3f(-width // 2, height // 2, 0.5)
    GL.glEnd()
开发者ID:sions,项目名称:arcade,代码行数:57,代码来源:draw_commands.py

示例7: draw

 def draw(self):
     gl.glPushMatrix()
     self.transform()
     gl.glBegin(gl.GL_QUADS)
     gl.glColor4ub(*self.color4)
     for v in self.vertexes:
         gl.glVertex3i(*v)
     gl.glEnd()
     gl.glPopMatrix()
开发者ID:1414648814,项目名称:cocos,代码行数:9,代码来源:mouse_elastic_box_selection.py

示例8: draw_bone

    def draw_bone(self, bone):
        p1 = bone.get_start()
        p2 = bone.get_end()

        gl.glColor4ub(*self.color)
        gl.glLineWidth(5)
        gl.glBegin(gl.GL_LINES)
        gl.glVertex2f(*p1)
        gl.glVertex2f(*p2)
        gl.glEnd()
开发者ID:fpietka,项目名称:cocos,代码行数:10,代码来源:skeleton.py

示例9: draw_rectangle

def draw_rectangle(x1, y1, x2, y2, color):
    if color is None:
        return
    glColor4ub(*(color + (255,)))
    glBegin(GL_QUADS)
    glVertex2f(x1, y1)
    glVertex2f(x2, y1)
    glVertex2f(x2, y2)
    glVertex2f(x1, y2)
    glEnd()
开发者ID:Matt-Esch,项目名称:anaconda,代码行数:10,代码来源:gui.py

示例10: draw_lines

def draw_lines(point_list, color, border_width=1):
    """
    Draw a set of lines.

    Draw a line between each pair of points specified.

    Args:
        :point_list: List of points making up the lines. Each point is
         in a list. So it is a list of lists.
        :color: color, specified in a list of 3 or 4 bytes in RGB or
         RGBA format.
        :border_width: Width of the line in pixels.
    Returns:
        None
    Raises:
        None

    Example:

    >>> import arcade
    >>> arcade.open_window("Drawing Example", 800, 600)
    >>> arcade.set_background_color(arcade.color.WHITE)
    >>> arcade.start_render()
    >>> point_list = ((390, 450), \
(450, 450), \
(390, 480), \
(450, 480), \
(390, 510), \
(450, 510))
    >>> arcade.draw_lines(point_list, arcade.color.BLUE, 3)
    >>> arcade.finish_render()
    >>> arcade.quick_run(0.25)
    """
    GL.glEnable(GL.GL_BLEND)
    GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)
    GL.glEnable(GL.GL_LINE_SMOOTH)
    GL.glHint(GL.GL_LINE_SMOOTH_HINT, GL.GL_NICEST)
    GL.glHint(GL.GL_POLYGON_SMOOTH_HINT, GL.GL_NICEST)

    GL.glLoadIdentity()

    # Set line width
    GL.glLineWidth(border_width)

    # Set color
    if len(color) == 4:
        GL.glColor4ub(color[0], color[1], color[2], color[3])
    elif len(color) == 3:
        GL.glColor4ub(color[0], color[1], color[2], 255)

    GL.glBegin(GL.GL_LINES)
    for point in point_list:
        GL.glVertex3f(point[0], point[1], 0.5)
    GL.glEnd()
开发者ID:sions,项目名称:arcade,代码行数:54,代码来源:draw_commands.py

示例11: draw_scores

 def draw_scores(self):
     """ Draws the scoreboard """
     gl.glBegin(gl.GL_QUADS)
     gl.glColor4ub(*[0,0,0,180])
     gl.glVertex2f(0,0)
     gl.glVertex2f(0,self.win.height)
     gl.glVertex2f(self.win.width,self.win.height)
     gl.glVertex2f(self.win.width,0)
     gl.glEnd()
         
     self.scores.draw()
开发者ID:Hugoagogo,项目名称:citySquare,代码行数:11,代码来源:main.py

示例12: draw

 def draw(self):
     gl.glPushMatrix()
     self.transform()
     gl.glBegin(gl.GL_QUADS)
     gl.glColor4ub(*(255, 255, 255, 255))
     for v in self.vertexes_out:
         gl.glVertex3i(*v)
     gl.glColor4ub(*(0, 150, 0, 255))
     for v in self.vertexes_in:
         gl.glVertex3i(*v)
     gl.glEnd()
     gl.glPopMatrix()
开发者ID:joaompinto,项目名称:SamePop,代码行数:12,代码来源:ProgressBar.py

示例13: render_rect_filled

def render_rect_filled(shape, x, y):
    """ Render the shape at the right spot. """
    # Set color
    GL.glDisable(GL.GL_BLEND)
    GL.glColor4ub(shape.color[0], shape.color[1], shape.color[2], 255)

    GL.glBindBuffer(GL.GL_ARRAY_BUFFER, shape.vbo_id)
    GL.glVertexPointer(2, GL.GL_FLOAT, 0, 0)

    GL.glLoadIdentity()
    GL.glTranslatef(x + shape.width / 2, y + shape.height / 2, 0)

    GL.glDrawArrays(GL.GL_QUADS, 0, shape.size)
开发者ID:apalm112,项目名称:arcade,代码行数:13,代码来源:vbo_test_01.py

示例14: draw_line

def draw_line(start_x, start_y, end_x, end_y, color, border_width=1):

    """
    Draw a line.

    Args:
        :start_x: x position of line starting point.
        :start_y: y position of line starting point.
        :end_x: x position of line ending point.
        :end_y: y position of line ending point.
        :color: color, specified in a list of 3 or 4 bytes in RGB or
         RGBA format.
        :border_width: Width of the line in pixels.
    Returns:
        None
    Raises:
        None

    Example:

    >>> import arcade
    >>> arcade.open_window("Drawing Example", 800, 600)
    >>> arcade.set_background_color(arcade.color.WHITE)
    >>> arcade.start_render()
    >>> arcade.draw_line(270, 495, 300, 450, arcade.color.WOOD_BROWN, 3)
    >>> color = (127, 0, 127, 127)
    >>> arcade.draw_line(280, 495, 320, 450, color, 3)
    >>> arcade.finish_render()
    >>> arcade.quick_run(0.25)
    """
    GL.glEnable(GL.GL_BLEND)
    GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)
    GL.glEnable(GL.GL_LINE_SMOOTH)
    GL.glHint(GL.GL_LINE_SMOOTH_HINT, GL.GL_NICEST)
    GL.glHint(GL.GL_POLYGON_SMOOTH_HINT, GL.GL_NICEST)

    GL.glLoadIdentity()

    # Set line width
    GL.glLineWidth(border_width)

    # Set color
    if len(color) == 4:
        GL.glColor4ub(color[0], color[1], color[2], color[3])
    elif len(color) == 3:
        GL.glColor4ub(color[0], color[1], color[2], 255)

    GL.glBegin(GL.GL_LINES)
    GL.glVertex3f(start_x, start_y, 0.5)
    GL.glVertex3f(end_x, end_y, 0.5)
    GL.glEnd()
开发者ID:sions,项目名称:arcade,代码行数:51,代码来源:draw_commands.py

示例15: draw_polygon_outline

def draw_polygon_outline(point_list, color, border_width=1):
    """
    Draw a polygon outline. Also known as a "line loop."

    Args:
        :point_list: List of points making up the lines. Each point is
         in a list. So it is a list of lists.
        :color: color, specified in a list of 3 or 4 bytes in RGB or
         RGBA format.
        :border_width: Width of the line in pixels.
    Returns:
        None
    Raises:
        None

    >>> import arcade
    >>> arcade.open_window("Drawing Example", 800, 600)
    >>> arcade.set_background_color(arcade.color.WHITE)
    >>> arcade.start_render()
    >>> point_list = ((30, 240), \
(45, 240), \
(60, 255), \
(60, 285), \
(45, 300), \
(30, 300))
    >>> arcade.draw_polygon_outline(point_list, arcade.color.SPANISH_VIOLET, 3)
    >>> arcade.finish_render()
    >>> arcade.quick_run(0.25)
    """
    GL.glEnable(GL.GL_BLEND)
    GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)
    GL.glEnable(GL.GL_LINE_SMOOTH)
    GL.glHint(GL.GL_LINE_SMOOTH_HINT, GL.GL_NICEST)
    GL.glHint(GL.GL_POLYGON_SMOOTH_HINT, GL.GL_NICEST)

    # Set line width
    GL.glLineWidth(border_width)

    GL.glLoadIdentity()

    # Set color
    if len(color) == 4:
        GL.glColor4ub(color[0], color[1], color[2], color[3])
    elif len(color) == 3:
        GL.glColor4ub(color[0], color[1], color[2], 255)

    GL.glBegin(GL.GL_LINE_LOOP)
    for point in point_list:
        GL.glVertex3f(point[0], point[1], 0.5)
    GL.glEnd()
开发者ID:sions,项目名称:arcade,代码行数:50,代码来源:draw_commands.py


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