Python blf.shadow() Examples

The following are 6 code examples of blf.shadow(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module blf , or try the search function .
Example #1
Source File: ops.py    From Screencast-Keys with GNU General Public License v3.0 6 votes vote down vote up
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) 
Example #2
Source File: ops.py    From Screencast-Keys with GNU General Public License v3.0 5 votes vote down vote up
def draw_text(text, font_id, color, shadow=False, shadow_color=None):
    blf.enable(font_id, blf.SHADOW)

    # Draw shadow.
    if shadow:
        blf.shadow_offset(font_id, 3, -3)
        blf.shadow(font_id, 5, *shadow_color, 1.0)

    # Draw text.
    compat.set_blf_font_color(font_id, *color, 1.0)
    blf.draw(font_id, text)

    blf.disable(font_id, blf.SHADOW) 
Example #3
Source File: render_time.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def draw_callback_px(self, context):
    scene = context.scene

    font_id = 0  # XXX, need to find out how best to get this.

    # draw some text
    blf.position(font_id, 15, 30, 0)
    blf.size(font_id, 18, 72)
    blf.enable(font_id, blf.SHADOW)
    blf.shadow(font_id, 5, 0.0, 0.0, 0.0, 1.0)

    # Shorten / cut off milliseconds
    time_total = str(timedelta(seconds = timer["total"]))
    pos = time_total.rfind(".")
    if pos != -1:
        time_total = time_total[0:pos+3]

    time_estimated = str(timedelta(seconds = (timer["average"] * (scene.frame_end - scene.frame_current))))
    pos = time_estimated.rfind(".")
    if pos != -1:
        time_estimated = time_estimated[0:pos]


    blf.draw(font_id, "Total render time " + time_total)
    if timer["is_rendering"] and scene.frame_current != scene.frame_start:
        blf.position(font_id, 15, 12, 0)
        blf.draw(font_id, "Estimated completion: " + time_estimated)

    # restore defaults
    blf.disable(font_id, blf.SHADOW) 
Example #4
Source File: fontmanager.py    From addon_common with GNU General Public License v3.0 5 votes vote down vote up
def shadow(level, rgba, fontid=None):
        return blf.shadow(FontManager.load(fontid), level, *rgba) 
Example #5
Source File: BakeLab_1_2.py    From Bakelab-Blender-addon with GNU General Public License v3.0 4 votes vote down vote up
def BakeLab_DrawCallback(self, context):
    props = context.scene.BakeLabProps
    ww = context.area.width
    wh = context.area.height
    
    bgl.glEnable(bgl.GL_BLEND)
    blf.enable(0,blf.SHADOW)
    blf.shadow(0,5,0,0.0,0.0,1)
    
    ######### Title {
    bgl.glBegin(bgl.GL_QUADS)
    bgl.glColor4f(0.88, 0.87, 0.85, 0.1)
    for i in range(0,20):
        bgl.glVertex2i(0,       wh)
        bgl.glVertex2i(120+i*3, wh)
        bgl.glVertex2i(120+i*3, wh-70)
        bgl.glVertex2i(0,       wh-70)
        
    bgl.glColor4f(0.7,0.1,0.3, 0.1)
    for i in range(0,20):
        bgl.glVertex2i(0,       wh-70)
        bgl.glVertex2i(140+i*3, wh-70)
        bgl.glVertex2i(140+i*3, wh-75)
        bgl.glVertex2i(0,       wh-75)
    bgl.glEnd()
    
    blf.size(0, 30, 72)
    bgl.glColor4f(0.7,0.1,0.3, 1.0)
    blf.position(0, 15, context.area.height-58, 0)
    blf.draw(0, 'BakeLab')
    ######### }
    
    ######### Progress {
    blf.size(0, 15, 72)
    y_shift = 15
    #######################################################################
    cur = self.bake_item_id
    max = len(context.scene.BakeLabMapColl)
    BakeLab_DrawProgressBar(y_shift,cur/max,'Map: '+ str(cur)+' of '+str(max))
    y_shift += 30
    #######################################################################
    if not props.s_to_a and not props.all_in_one:
        cur = self.bake_obj_id
        max = len(self.bake_objs)
        BakeLab_DrawProgressBar(y_shift,cur/max,'Object: '+ str(cur)+' of '+str(max))
        y_shift += 30
    #######################################################################
    if props.use_list:
        cur = self.ObjListIndex
        max = len(context.scene.BakeLabObjColl)
        BakeLab_DrawProgressBar(y_shift,cur/max,'List: '+ str(cur)+' of '+str(max))
        y_shift += 30
    #######################################################################
    ######### }
    
    
    blf.disable(0,blf.SHADOW)
    bgl.glDisable(bgl.GL_BLEND)
    bgl.glColor4f(0.0, 0.0, 0.0, 1.0) 
Example #6
Source File: mesh_show_vgroup_weights.py    From Fluid-Designer with GNU General Public License v3.0 4 votes vote down vote up
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