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


Python bgl.glColor3f方法代码示例

本文整理汇总了Python中bgl.glColor3f方法的典型用法代码示例。如果您正苦于以下问题:Python bgl.glColor3f方法的具体用法?Python bgl.glColor3f怎么用?Python bgl.glColor3f使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bgl的用法示例。


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

示例1: draw_line

# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glColor3f [as 别名]
def draw_line(p1, p2, color, shadow=False, shadow_color=None):
    bgl.glEnable(bgl.GL_BLEND)
    bgl.glEnable(bgl.GL_LINE_SMOOTH)

    # Draw shadow.
    if shadow:
        bgl.glLineWidth(3.0)
        bgl.glColor4f(*shadow_color, 1.0)
        bgl.glBegin(bgl.GL_LINES)
        bgl.glVertex2f(*p1)
        bgl.glVertex2f(*p2)
        bgl.glEnd()

    # Draw line.
    bgl.glLineWidth(1.5 if shadow else 1.0)
    bgl.glColor3f(*color)
    bgl.glBegin(bgl.GL_LINES)
    bgl.glVertex2f(*p1)
    bgl.glVertex2f(*p2)
    bgl.glEnd()

    bgl.glLineWidth(1.0)
    bgl.glDisable(bgl.GL_LINE_SMOOTH) 
开发者ID:nutti,项目名称:Screencast-Keys,代码行数:25,代码来源:ops.py

示例2: draw_rect

# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glColor3f [as 别名]
def draw_rect(x1, y1, x2, y2, color):
    bgl.glColor3f(*color)

    bgl.glBegin(bgl.GL_QUADS)
    bgl.glVertex2f(x1, y1)
    bgl.glVertex2f(x1, y2)
    bgl.glVertex2f(x2, y2)
    bgl.glVertex2f(x2, y1)
    bgl.glEnd()

    bgl.glColor3f(1.0, 1.0, 1.0) 
开发者ID:nutti,项目名称:Screencast-Keys,代码行数:13,代码来源:ops.py

示例3: draw_callback

# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glColor3f [as 别名]
def draw_callback(self, context):
    # polling
    if context.mode == 'EDIT_MESH':
        return

    """
    # retrieving ID property data
    try:
        texts = context.scene['GamePropsVisualizer']
    except:
        return

    if not texts:
        return
    """

    texts = context.scene['GamePropsVisualizer']

    # draw
    i = 0

    blf.size(0, 12, 72)


    bgl.glColor3f(1.0, 1.0, 1.0)
    for ob in bpy.context.selected_objects:
        for pi,p in enumerate(ob.game.properties):
            blf.position(0, texts[i], texts[i+1] - (pi+1) * 14, 0)
            if p.type=='FLOAT':
                t=p.name+':  '+ str('%g' % p.value)
            else:
                t=p.name+':  '+ str(p.value)
            blf.draw(0, t)
            i += 2


# operator 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:39,代码来源:space_view3d_game_props_visualiser.py

示例4: glColor

# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glColor3f [as 别名]
def glColor(color):
    if len(color) == 3:
        bgl.glColor3f(*color)
    else:
        bgl.glColor4f(*color) 
开发者ID:CGCookie,项目名称:addon_common,代码行数:7,代码来源:bmesh_render.py

示例5: drawCallback

# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glColor3f [as 别名]
def drawCallback(self):
        mat = self.interfacer.getBlenderObject().matrix_world
        if self.do_draw and self.interfacer.isClean():
            # isClean() is not really needed here, but it shows its
            # behavior and helps reducing (a tiny bit!) the run time...
            bgl.glColor3f(0.0, 1.0, 1.0)
            bgl.glPointSize(5)
            bgl.glBegin(bgl.GL_POINTS)
            for v in self.vertices:
                bgl.glVertex3f(*(mat*v))
            bgl.glEnd()
            bgl.glPointSize(1)

            bgl.glColor3f(1.0, 1.0, 0.0)
            bgl.glLineWidth(2)
            bgl.glBegin(bgl.GL_LINES)
            for v, w in zip(self.vertices, self.velocities):
                bgl.glVertex3f(*(mat*v))
                bgl.glVertex3f(*(mat*(v + w)))
            bgl.glEnd()
            bgl.glLineWidth(1)


# this in toplevel is also requested
# MAIN_CLASS should be set to any callable returning the
# requested instance, which provides the update() method. 
开发者ID:qwenger,项目名称:BAddons,代码行数:28,代码来源:ogl_velocitiesrenderer.py

示例6: drawO

# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glColor3f [as 别名]
def drawO(self, xa, xb, ya, yb):
        bgl.glColor3f(*self.COLOR_O)
        r = xb - xa
        bgl.glVertex3f(xa + r*self.EMPTY_FACTOR, (ya + yb)/2.0, 0.0)
        bgl.glVertex3f((xa + xb)/2.0, yb - r*self.EMPTY_FACTOR, 0.0)
        bgl.glVertex3f((xa + xb)/2.0, yb - r*self.EMPTY_FACTOR, 0.0)
        bgl.glVertex3f(xb - r*self.EMPTY_FACTOR, (ya + yb)/2.0, 0.0)
        bgl.glVertex3f(xb - r*self.EMPTY_FACTOR, (ya + yb)/2.0, 0.0)
        bgl.glVertex3f((xa + xb)/2.0, ya + r*self.EMPTY_FACTOR, 0.0)
        bgl.glVertex3f((xa + xb)/2.0, ya + r*self.EMPTY_FACTOR, 0.0)
        bgl.glVertex3f(xa + r*self.EMPTY_FACTOR, (ya + yb)/2.0, 0.0) 
开发者ID:qwenger,项目名称:BAddons,代码行数:13,代码来源:3dview_play_tictactoe.py

示例7: drawX

# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glColor3f [as 别名]
def drawX(self, xa, xb, ya, yb):
        bgl.glColor3f(*self.COLOR_X)
        r = xb - xa
        bgl.glVertex3f(xa + r*self.EMPTY_FACTOR, ya + r*self.EMPTY_FACTOR, 0.0)
        bgl.glVertex3f(xb - r*self.EMPTY_FACTOR, yb - r*self.EMPTY_FACTOR, 0.0)
        bgl.glVertex3f(xa + r*self.EMPTY_FACTOR, yb - r*self.EMPTY_FACTOR, 0.0)
        bgl.glVertex3f(xb - r*self.EMPTY_FACTOR, ya + r*self.EMPTY_FACTOR, 0.0) 
开发者ID:qwenger,项目名称:BAddons,代码行数:9,代码来源:3dview_play_tictactoe.py

示例8: drawPoint

# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glColor3f [as 别名]
def drawPoint(x, y, main=True):
        r = 6 if main else 3

        bgl.glBegin(bgl.GL_LINES)
        bgl.glColor3f(1.0, 1.0, 1.0)
        bgl.glVertex2i(x - r, y)
        bgl.glVertex2i(x - r, y + r)
        bgl.glVertex2i(x - r, y + r)
        bgl.glVertex2i(x, y + r)
        
        bgl.glVertex2i(x + r, y)
        bgl.glVertex2i(x + r, y - r)
        bgl.glVertex2i(x + r, y - r)
        bgl.glVertex2i(x, y - r)
        
        bgl.glColor3f(0.0, 0.0, 0.0)
        bgl.glVertex2i(x, y + r)
        bgl.glVertex2i(x + r, y + r)
        bgl.glVertex2i(x + r, y + r)
        bgl.glVertex2i(x + r, y)
        
        bgl.glVertex2i(x, y - r)
        bgl.glVertex2i(x - r, y - r)
        bgl.glVertex2i(x - r, y - r)
        bgl.glVertex2i(x - r, y)
        bgl.glEnd() 
开发者ID:qwenger,项目名称:BAddons,代码行数:28,代码来源:node_colorramp_dropper.py

示例9: draw_rounded_box

# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glColor3f [as 别名]
def draw_rounded_box(x, y, w, h, round_radius, fill=False, color=[1.0, 1.0, 1.0],
                     round_corner=[True, True, True, True]):
    """round_corner: [Right Bottom, Left Bottom, Right Top, Left Top]"""

    def circle_verts_num(r):
        """Get number of verticies for circle optimized for drawing."""

        num_verts = 32
        threshold = 2.0  # pixcel
        while True:
            if r * 2 * math.pi / num_verts > threshold:
                return num_verts
            num_verts -= 4
            if num_verts < 1:
                return 1

    num_verts = circle_verts_num(round_radius)
    n = int(num_verts / 4) + 1
    dangle = math.pi * 2 / num_verts

    radius = [round_radius if rc else 0 for rc in round_corner]

    x_origin = [
        x + radius[0],
        x + w - radius[1],
        x + w - radius[2],
        x + radius[3],
    ]
    y_origin = [
        y + radius[0],
        y + radius[1],
        y + h - radius[2],
        y + h - radius[3],
    ]
    angle_start = [
        math.pi * 1.0,
        math.pi * 1.5,
        math.pi * 0.0,
        math.pi * 0.5,
    ]

    bgl.glColor3f(*color)
    if fill:
        bgl.glBegin(bgl.GL_TRIANGLE_FAN)
    else:
        bgl.glBegin(bgl.GL_LINE_LOOP)
    for x0, y0, angle, r in zip(x_origin, y_origin, angle_start, radius):
        for _ in range(n):
            x = x0 + r * math.cos(angle)
            y = y0 + r * math.sin(angle)
            bgl.glVertex2f(x, y)
            angle += dangle
    bgl.glEnd()
    bgl.glColor3f(1.0, 1.0, 1.0) 
开发者ID:nutti,项目名称:Screencast-Keys,代码行数:56,代码来源:ops.py

示例10: draw_callback

# 需要导入模块: import bgl [as 别名]
# 或者: from bgl import glColor3f [as 别名]
def draw_callback(self, context):
    # polling
    if context.mode != "EDIT_MESH" or len(context.active_object.vertex_groups) == 0:
        return
    # retrieving ID property data
    try:
        texts = context.active_object.data["show_vgroup_verts"]
        weights = context.active_object.data["show_vgroup_weights"]
    except:
        return
    if not texts:
        return

    bm = bmesh.from_edit_mesh(context.active_object.data)

    if bm.select_mode == {'VERT'} and bm.select_history.active is not None:
        active_vert = bm.select_history.active
    else:
        active_vert = None

    # draw
    blf.size(0, 13, 72)
    blf.enable(0, blf.SHADOW)
    blf.shadow(0, 3, 0.0, 0.0, 0.0, 1.0)
    blf.shadow_offset(0, 2, -2)
    for i in range(0, len(texts), 7):
        bgl.glColor3f(texts[i], texts[i+1], texts[i+2])
        blf.position(0, texts[i+4], texts[i+5], texts[i+6])
        blf.draw(0, "Vertex " + str(int(texts[i+3])) + ":")
        font_y = texts[i+5]
        group_name = ""
        for j in range(0, len(weights), 3):
            if int(weights[j]) == int(texts[i+3]):
                font_y -= 13
                blf.position(0, texts[i+4] + 10, font_y, texts[i+6])
                for group in context.active_object.vertex_groups:
                    if group.index == int(weights[j+1]):
                        group_name = group.name
                        break
                blf.draw(0, group_name + ": %.3f" % weights[j+2])
        if group_name == "":
            font_y -= 13
            blf.position(0, texts[i+4] + 10, font_y, texts[i+6])
            blf.draw(0, "No Groups")

    # restore defaults
    blf.disable(0, blf.SHADOW)


# operator 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:52,代码来源:mesh_show_vgroup_weights.py


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