def draw_string(self, color1, color2, left, bottom, text, max_option, divide = 1):
    """ Draw the text like 'option : key' or just 'option' """

    font_id = 0
    ui_scale = bpy.context.preferences.system.ui_scale

    blf.enable(font_id,blf.SHADOW)
    blf.shadow(font_id, 0, 0.0, 0.0, 0.0, 1.0)
    blf.shadow_offset(font_id,2,-2)
    line_height = (blf.dimensions(font_id, "gM")[1] * 1.45)
    y_offset = 5

    # Test if the text is a list formatted like : ('option', 'key')
    if isinstance(text,list):
        spacer_text = " : "
        spacer_width = blf.dimensions(font_id, spacer_text)[0]
        for string in text:
            blf.position(font_id, (left), (bottom + y_offset), 0)
            blf.color(font_id, *color1)
            blf.draw(font_id, string[0])
            blf.position(font_id, (left + max_option), (bottom + y_offset), 0)
            blf.draw(font_id, spacer_text)
            blf.color(font_id, *color2)
            blf.position(font_id, (left + max_option + spacer_width), (bottom + y_offset), 0)
            blf.draw(font_id, string[1])
            y_offset += line_height
    else:
        # The text is formatted like : ('option')
        blf.position(font_id, left, (bottom + y_offset), 0)
        blf.color(font_id, *color1)
        blf.draw(font_id, text)
        y_offset += line_height

    blf.disable(font_id,blf.SHADOW)
Пример #2
0
    def _draw_pixels(self, context, depsgraph):

        scene = depsgraph.scene
        w = context.region.width
        h = context.region.height

        # Draw text area that RenderMan is running.
        if get_pref('draw_ipr_text',
                    False) and not self.rman_render.rman_is_viewport_rendering:

            pos_x = w / 2 - 100
            pos_y = 20
            blf.enable(0, blf.SHADOW)
            blf.shadow_offset(0, 1, -1)
            blf.shadow(0, 5, 0.0, 0.0, 0.0, 0.8)
            blf.size(0, 32, 36)
            blf.position(0, pos_x, pos_y, 0)
            blf.color(0, 1.0, 0.0, 0.0, 1.0)
            blf.draw(0, "%s" % ('RenderMan Interactive Mode Running'))
            blf.disable(0, blf.SHADOW)

        if not self.rman_render.rman_is_viewport_rendering:
            return

        # Bind shader that converts from scene linear to display space,
        bgl.glEnable(bgl.GL_BLEND)
        bgl.glBlendFunc(bgl.GL_ONE, bgl.GL_ONE_MINUS_SRC_ALPHA)
        self.bind_display_space_shader(scene)

        self.rman_render.draw_pixels(w, h)

        self.unbind_display_space_shader()
        bgl.glDisable(bgl.GL_BLEND)
Пример #3
0
    def __render(self, context):
        prefs = context.user_preferences.addons[__name__].preferences

        region, space = ShowObjectName.__get_region_space(
            context, 'VIEW_3D', 'WINDOW', 'VIEW_3D'
        )
        if (region is None) or (space is None):
            return

        # オブジェクトの位置にオブジェクト名を表示
        objs = [o for o in bpy.data.objects]
        # オブジェクトの位置座標(3D座標)をリージョン座標(2D座標)に変換
        locs_on_screen = [
            view3d_utils.location_3d_to_region_2d(
                region,
                space.region_3d,
                o.location
            ) for o in objs
        ]
        blf.shadow(0, 3, 0.1, 0.1, 0.1, 1.0)
        blf.shadow_offset(0, 1, -1)
        blf.enable(0, blf.SHADOW)
        for obj, loc in zip(objs, locs_on_screen):
            # 表示範囲外なら表示しない
            if loc is not None:
                ShowObjectName.__render_message(
                    prefs.font_size_2, loc.x, loc.y, obj.name
                )
        blf.disable(0, blf.SHADOW)

        # マウスカーソルの位置に向けて発したレイと交差するオブジェクト名を表示
        blf.shadow(0, 3, 0.0, 1.0, 0.0, 0.5)
        blf.shadow_offset(0, 2, -2)
        blf.enable(0, blf.SHADOW)
        ShowObjectName.__render_message(
            prefs.font_size_1,
            prefs.left_top[0],
            region.height - prefs.left_top[1],
            "Intersect"
        )
        blf.disable(0, blf.SHADOW)
        # ray_castが可能なオブジェクトモード時のみ表示
        if context.mode == 'OBJECT':
            for i, o in enumerate(self.__intersected_objs):
                ShowObjectName.__render_message(
                    int(prefs.font_size_1 * 0.8),
                    prefs.left_top[0],
                    (region.height - prefs.left_top[1]
                     - int(prefs.font_size_1 * 1.3)
                     - i * int(prefs.font_size_1 * 0.9)),
                    o.name
                )
        else:
            ShowObjectName.__render_message(
                int(prefs.font_size_1 * 0.8),
                prefs.left_top[0],
                (region.height - prefs.left_top[1]
                 - int(prefs.font_size_1 * 1.3)),
                "Objectモード以外では利用できません"
            )
Пример #4
0
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)
Пример #5
0
def displayShadow():
    blf.enable(font_id, blf.SHADOW)
    blf.shadow(font_id, 3,
               getValue('shadowColor')[0],
               getValue('shadowColor')[1],
               getValue('shadowColor')[2], 0.8)
    blf.shadow_offset(font_id, getValue('shOffsetX'), getValue('shOffsetY'))
Пример #6
0
	def draw(self, text, x, y):
		if self.shadowed:
			blf.enable(self.id, blf.SHADOW)
			blf.shadow_offset(self.id, self.shadow_offset[0],
				self.shadow_offset[1])
			blf.shadow(self.id, 3, 0, 0, 0, 0.8)
		else:
			blf.disable(self.id, blf.SHADOW)

		_, h = self.measure("E]")

		blf.position(self.id, x, -y, 0)
		blf.size(self.id, int(self.size), 72)

		glPushMatrix()
		glLoadIdentity()
		# horrible hack for issue #1
		if Font.first:
			glTranslatef(0, h / 2 + 4, 0)
			Font.first = False
		else:
			glTranslatef(0, h, 0)
		glScalef(1, -1, 1)
		blf.draw(self.id, text)
		glPopMatrix()

		if self.shadowed:
			blf.disable(self.id, blf.SHADOW)
def write_interaction_status():
    """
    Write the interaction status on Screen
    The status is stored in a property
    """
    cam = blenderapi.scene().active_camera

    # get the suffix of the human to reference the right objects
    suffix = cam.name[-4:] if cam.name[-4] == "." else ""

    hand = objects['Hand_Grab.R' + suffix]

    # OpenGL setup
    bgl.glMatrixMode(bgl.GL_PROJECTION)
    bgl.glLoadIdentity()
    bgl.gluOrtho2D(0, windowWidth, 0, windowHeight)
    bgl.glMatrixMode(bgl.GL_MODELVIEW)
    bgl.glLoadIdentity()

    blf.size(font_id, int(windowHeight * 0.04), 72)
    # draw a black shadow around the text
    blf.enable(font_id, blf.SHADOW)
    blf.shadow(font_id, 5, 0.0, 0.0, 0.0, 1.0)
    blf.position(font_id, windowWidth * 0.4, windowHeight * 0.4, 0)
    blf.draw(font_id, hand['Status'])
def draw_callback_px(self, context, pos):
    val = self.cyl_sides
    hpos, vpos = 64, 64
    if pos: hpos = pos - 110
    if val:
        font_id = 0
        blf.enable(font_id, 4)
        blf.position(font_id, hpos, vpos + 64, 0)
        blf.color(font_id, self.hcol[0], self.hcol[1], self.hcol[2],
                  self.hcol[3])
        blf.size(font_id, 20, 72)
        blf.shadow(font_id, 5, 0, 0, 0, 1)
        blf.shadow_offset(font_id, 1, -1)
        blf.draw(font_id, "Cylinder Sides: " + str(val))
        blf.size(font_id, 15, 72)
        blf.position(font_id, hpos, vpos + 40, 0)
        blf.color(font_id, self.tcol[0], self.tcol[1], self.tcol[2],
                  self.tcol[3])
        blf.draw(font_id, "Increment: Mouse Wheel Up / Down")
        blf.position(font_id, hpos, vpos + 20, 0)
        blf.draw(font_id, "Apply:        LMB, RMB, Esc, Enter or Spacebar")
        blf.size(font_id, 10, 72)
        blf.position(font_id, hpos, vpos, 0)
        blf.color(font_id, self.scol[0], self.scol[1], self.scol[2],
                  self.scol[3])
        blf.draw(
            font_id,
            "Navigation: Blender (-MMB) or Ind.Std (Alt-) Defaults Pass-Through"
        )
    else:
        return {'CANCELLED'}
Пример #9
0
def draw_text(font_id, str_list, area, dim_y):
    line_spacing = [(dim_y * 2) * i for i in range(len(str_list))]
    scale = bpy.context.preferences.view.ui_scale
    font_size = round(11 * scale)
    x = (20 * scale) + area.regions[2].width
    y = area.height - (line_spacing[1] * 8 * scale)

    for ofs_y, string in zip(line_spacing, str_list):
        blf.shadow(font_id, 3, 0, 0, 0, 0.75)
        blf.enable(font_id, blf.SHADOW)
        blf.position(font_id, x, y - (ofs_y * scale), 0)
        blf.size(font_id, font_size, 72)
        blf.color(font_id, 1, 1, 1, 1)

        if isinstance(string, tuple):
            blf.color(font_id, 1, 1, 0, 1)
            ofs_x = 0

            for substring in string:
                blf.position(font_id, x + ofs_x, y - (ofs_y * scale), 0)
                ofs_x += (blf.dimensions(0, "M")[0] + 30) * scale
                blf.draw(font_id, substring)
                blf.color(font_id, 1, 1, 1, 1)
        else:
            blf.draw(font_id, string)
Пример #10
0
    def draw(self, text, x, y):
        if self.shadowed:
            blf.enable(self.id, blf.SHADOW)
            blf.shadow_offset(self.id, self.shadow_offset[0],
                              self.shadow_offset[1])
            blf.shadow(self.id, 3, 0, 0, 0, 0.8)
        else:
            blf.disable(self.id, blf.SHADOW)

        _, h = self.measure("E]")

        blf.position(self.id, x, -y, 0)
        blf.size(self.id, int(self.size), 72)

        glPushMatrix()
        glLoadIdentity()
        # horrible hack for issue #1
        if Font.first:
            glTranslatef(0, h / 2 + 4, 0)
            Font.first = False
        else:
            glTranslatef(0, h, 0)
        glScalef(1, -1, 1)
        blf.draw(self.id, text)
        glPopMatrix()

        if self.shadowed:
            blf.disable(self.id, blf.SHADOW)
Пример #11
0
def write_interaction_status():
    """
    Write the interaction status on Screen
    The status is stored in a property
    """
    cam = logic.getCurrentScene().active_camera

    # get the suffix of the human to reference the right objects
    suffix = cam.name[-4:] if cam.name[-4] == "." else ""
    
    hand = objects['Hand_Grab.R' + suffix]
    
    # OpenGL setup
    bgl.glMatrixMode(bgl.GL_PROJECTION)
    bgl.glLoadIdentity()
    bgl.gluOrtho2D(0, windowWidth, 0, windowHeight)
    bgl.glMatrixMode(bgl.GL_MODELVIEW)
    bgl.glLoadIdentity()
    
    blf.size(font_id, int(windowHeight*0.04), 72)
    # draw a black shadow around the text
    blf.enable(font_id, blf.SHADOW)
    blf.shadow(font_id, 5, 0.0, 0.0, 0.0, 1.0)
    blf.position(font_id, windowWidth*0.4, windowHeight*0.4,0)
    blf.draw(font_id, hand['Status'])
Пример #12
0
def spnumdisplay(disp_op, context, simnode):
    scene = context.scene
    leg = 0 if simnode.bl_label == 'VI Sun Path' else 1
    if bpy.data.objects.get('SPathMesh'):
        ob = bpy.data.objects['SPathMesh']    
        if scene.hourdisp == True:
            blf.enable(0, 4)
            blf.shadow(0, 5,scene.vi_display_rp_fsh[0], scene.vi_display_rp_fsh[1], scene.vi_display_rp_fsh[2], scene.vi_display_rp_fsh[3])
            bgl.glColor4f(scene.vi_display_rp_fc[0], scene.vi_display_rp_fc[1], scene.vi_display_rp_fc[2], scene.vi_display_rp_fc[3])
            blf.size(0, scene.vi_display_rp_fs, 72)
            mid_x, mid_y, width, height = viewdesc(context)
            view_mat = context.space_data.region_3d.perspective_matrix
            view_pivot = bpy.context.active_object.location if bpy.context.active_object and context.user_preferences.view.use_rotate_around_active else context.region_data.view_location

            if context.space_data.region_3d.is_perspective:
                vw = mathutils.Vector((-view_mat[3][0], -view_mat[3][1], -view_mat[3][2])).normalized()
                view_location = view_pivot + vw.normalized() * bpy.context.region_data.view_distance        
            else:
                vw =  mathutils.Vector((0.0, 0.0, 1.0))
                vw.rotate(bpy.context.region_data.view_rotation)
                view_location = view_pivot + vw.normalized()*bpy.context.region_data.view_distance*10 

            ob_mat = ob.matrix_world
            total_mat = view_mat * ob_mat
            posis = [total_mat*mathutils.Vector(co).to_4d() for co in ob['numpos'].values() if mathutils.Vector.angle(vw, view_location - ob_mat*mathutils.Vector(co)) < pi * 0.5 and not scene.ray_cast(0.95*ob_mat*mathutils.Vector(co), view_location)[0]]
            hs = [int(t.split('-')[1]) for t in ob['numpos'].keys() if total_mat*mathutils.Vector(ob['numpos'][t]).to_4d() in posis]
            draw_index(context, leg, mid_x, mid_y, width, height, posis, hs)
            blf.disable(0, 4)
    else:
        return
def draw_callback(self, context):
    init_offset = get_init_display_offset()
    offset_x = init_offset[0]
    offset_y = bpy.context.region.height - init_offset[1]
    area = bpy.context.area
    tools_region = None
    header_region = None

    if area.spaces[0].overlay.show_overlays == False:
        return

    for region in area.regions:
        if region.type == 'TOOLS':
            tools_region = region
        elif region.type == 'HEADER':
            header_region = region

    if bpy.context.region.y != header_region.y:
        offset_y -= header_region.height

    if area.spaces[0].show_region_toolbar and tools_region != None:
        offset_x += tools_region.width

    if version >= (2, 90, 0) and area.spaces[0].overlay.show_stats:
        offset_y -= 108

    blf.position(font_id, offset_x, offset_y, 0)
    blf.size(font_id, font_size, font_dpi)
    blf.enable(font_id, blf.SHADOW)
    blf.shadow(font_id, 3, 0, 0, 0, font_shadow_alpha)
    blf.shadow_offset(font_id, 1, -2)
    blf.draw(font_id,
             get_collection_string(bpy.context.view_layer.objects.active))
Пример #14
0
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)
Пример #15
0
def write():
    """
    Write the name of all active objects on Screen
    """
    # OpenGL setup
    bgl.glMatrixMode(bgl.GL_PROJECTION)
    bgl.glLoadIdentity()
    bgl.gluOrtho2D(0, windowWidth, 0, windowHeight)
    bgl.glMatrixMode(bgl.GL_MODELVIEW)
    bgl.glLoadIdentity()

    cam = scene.active_camera

    for obj in passive_objects.active_objects():
        # test if the object is in the view frustum
        if cam.pointInsideFrustum(obj.worldPosition):
            pos = cam.getScreenPosition(obj)

            blf.size(font_id, int(windowWidth * 0.02), 72)
            # draw a black shadow to increase contrast with white parts
            blf.enable(font_id, blf.SHADOW)
            blf.shadow(font_id, 5, 0.0, 0.0, 0.0, 1.0)
            blf.position(font_id, pos[0] * windowWidth,
                         (1 - pos[1]) * windowHeight, 0)
            blf.draw(font_id, obj.name)
Пример #16
0
def h_draw_text(fid, text, bounds, color, margin=0, font_size=16, text_align=0, vertical_align=0, shadow=False, clip=True):
    text = str(text)
    width = render.getWindowWidth()
    height = render.getWindowHeight()
    
    #bgl.glColor4f(*(1, 0, 0, 1))
    #h_draw_quad_wire(bounds)
    
    if clip:
        h_clip_begin(bounds)
    
    blf.size(fid, font_size, 72)
    if shadow:
        blf.enable(fid, blf.SHADOW)
        blf.shadow(fid, 3, 0.0, 0.0, 0.0, 1.0)
        blf.shadow_offset(fid, 0, -1)
    else:
        blf.disable(fid, blf.SHADOW)
    bgl.glPushMatrix()
    
    # Fix upside-down text =)
    w, h = blf.dimensions(fid, text)
    bgl.glTranslated(0.0, h, 0.0)
    bgl.glScalef(1.0, -1.0, 1.0)
    
    bgl.glColor4f(*color)

    texts = text.split("\n")
    yn = 0
    if vertical_align == 0:
        yn = margin
    elif vertical_align == 1:
        yn = bounds[3]/2-(h*len(texts))/2
    elif vertical_align == 2:
        yn = (bounds[3]-(h*len(texts)))-margin
    for i in range(len(texts)):            
        texts[i] = texts[i].replace("\t", "        ")
        wl, hl = blf.dimensions(fid, texts[i])
        xn = 0
        
        if text_align == 0:
            xn = margin
        elif text_align == 1:
            xn = bounds[2]/2-wl/2
        elif text_align == 2:
            xn = (bounds[2]-wl)-margin
            
        blf.position(fid, bounds[0]+xn, -bounds[1]-(i*h)-yn, 1)
        
        blf.draw(fid, texts[i])
        
    bgl.glScalef(1.0, 1.0, 1.0)
    bgl.glPopMatrix()
    
    if clip:
        h_clip_end()
Пример #17
0
    def __render_working_hours(self, context):
        sc = context.scene
        props = sc.cwh_props
        prefs = context.user_preferences.addons[__name__].preferences

        # 表示するオブジェクトが選択されていない場合は、描画しない
        if sc.cwh_prop_object == '':
            return

        # リージョン幅を取得するため、描画先のリージョンを得る
        region = CalculateWorkingHours.__get_region(
            context, 'VIEW_3D', 'WINDOW'
        )

        # 描画先のリージョンへ文字列を描画
        if region is not None:
            # 影の効果を設定
            blf.shadow(0, 3, 0.0, 1.0, 0.0, 0.5)
            # 影の位置を設定
            blf.shadow_offset(0, 2, -2)
            # 影の効果を有効化
            blf.enable(0, blf.SHADOW)
            CalculateWorkingHours.__render_message(
                int(prefs.font_size * 1.3),
                prefs.left_top[0],
                region.height - prefs.left_top[1],
                "Working Hour"
            )
            # 影の効果を無効化
            blf.disable(0, blf.SHADOW)
            CalculateWorkingHours.__render_message(
                prefs.font_size,
                prefs.left_top[0],
                region.height - int(prefs.left_top[1] + prefs.font_size * 1.5),
                "Object: " + sc.cwh_prop_object
            )
            CalculateWorkingHours.__render_message(
                prefs.font_size,
                prefs.left_top[0],
                region.height - int(
                    prefs.left_top[1] + prefs.font_size * (1.5 + 2.5)
                ),
                "Object Mode: " + CalculateWorkingHours.__make_time_fmt(
                    props.working_hour_db[sc.cwh_prop_object]['OBJECT']
                )
            )
            CalculateWorkingHours.__render_message(
                prefs.font_size,
                prefs.left_top[0],
                region.height - int(
                    prefs.left_top[1] + prefs.font_size * (1.5 + 4.0)
                ),
                "Edit Mode: " + CalculateWorkingHours.__make_time_fmt(
                    props.working_hour_db[sc.cwh_prop_object]['EDIT']
                )
            )
Пример #18
0
def draw_callback_px(self, context, position, rotation):
    font_id = font_info["font_id"]
    blf.enable(font_id, blf.ROTATION)

    blf.rotation(font_id, math.radians(45))
    blf.position(font_id, position[0] - 280, position[1] - 280, 0)
    # blf.position(font_id, 3, 3, 0)

    blf.size(font_id, 10, 300)
    blf.draw(font_id, "Hello World")
Пример #19
0
def draw_ui(self, context, _uidpi, _uifactor):
    def get_target():
        if self.target == context.scene.cursor:
            return "3D Cursor"
        elif self.target == context.view_layer.objects.active:
            return "Active object"

    prefs = bpy.context.preferences.addons['InteractionOps'].preferences
    tColor = prefs.text_color
    tKColor = prefs.text_color_key
    tCSize = prefs.text_size
    tCPosX = prefs.text_pos_x
    tCPosY = prefs.text_pos_y
    tShadow = prefs.text_shadow_toggle
    tSColor = prefs.text_shadow_color
    tSBlur = prefs.text_shadow_blur
    tSPosX = prefs.text_shadow_pos_x
    tSPosY = prefs.text_shadow_pos_y

    _target = get_target()
    iops_text = (
        ("Look at", str(_target)),
        ("Look at axis", str(self.look_axis[0])),
        ("Match cursor's rotation", str(self.rotate)),
        ("Align to cursor's pos", "F3"),
        ("Visual origin helper", "F4"),
    )

    # FontID
    font = 0
    blf.color(font, tColor[0], tColor[1], tColor[2], tColor[3])
    blf.size(font, tCSize, _uidpi)
    if tShadow:
        blf.enable(font, blf.SHADOW)
        blf.shadow(font, int(tSBlur), tSColor[0], tSColor[1], tSColor[2],
                   tSColor[3])
        blf.shadow_offset(font, tSPosX, tSPosY)
    else:
        blf.disable(0, blf.SHADOW)

    textsize = tCSize
    # get leftbottom corner
    offset = tCPosY
    columnoffs = (textsize * 15) * _uifactor
    for line in reversed(iops_text):
        blf.color(font, tColor[0], tColor[1], tColor[2], tColor[3])
        blf.position(font, tCPosX * _uifactor, offset, 0)
        blf.draw(font, line[0])

        blf.color(font, tKColor[0], tKColor[1], tKColor[2], tKColor[3])
        textdim = blf.dimensions(0, line[1])
        coloffset = columnoffs - textdim[0] + tCPosX
        blf.position(0, coloffset, offset, 0)
        blf.draw(font, line[1])
        offset += (tCSize + 5) * _uifactor
def DynamicNodes_Arrange_DrawCallBack(self, context):
    bgl.glColor4f(0.6, 0.6, 0.7, 1)
    font_id = 0
    blf.size(font_id, 12, 0)
    blf.enable(font_id, blf.SHADOW)
    blf.shadow(font_id, 3, 0, 0, 0, 1)
    props = context.scene.DynamicNodes_Properties

    blf.position(font_id, 12, context.area.height - 50, 0)
    blf.draw(
        font_id,
        str(min(self.iteration_cnt, props.step1)) + '/' + str(props.step1))
    blf.position(font_id, 12, context.area.height - 70, 0)
    blf.draw(
        font_id,
        str(min(max(self.iteration_cnt - props.step1, 0), props.step2)) + '/' +
        str(props.step2))
    blf.position(font_id, 12, context.area.height - 90, 0)
    blf.draw(
        font_id,
        str(
            min(max(self.iteration_cnt - props.step1 - props.step2, 0),
                props.step3)) + '/' + str(props.step3))
    blf.position(font_id, 12, context.area.height - 110, 0)
    blf.draw(
        font_id,
        str(
            max(self.iteration_cnt - props.step1 - props.step2 - props.step3,
                0)) + '/' + str(props.step4))

    bgl.glBegin(bgl.GL_QUADS)
    bgl.glColor4f(0.7, 0.7, 1.0, 1.0)
    bgl.glVertex2i(8, context.area.height - 128)
    bgl.glVertex2i(52, context.area.height - 128)
    bgl.glVertex2i(52, context.area.height - 142)
    bgl.glVertex2i(8, context.area.height - 142)

    bgl.glColor4f(0.1, 0.1, 0.1, 1.0)
    bgl.glVertex2i(9, context.area.height - 129)
    bgl.glVertex2i(51, context.area.height - 129)
    bgl.glVertex2i(51, context.area.height - 141)
    bgl.glVertex2i(9, context.area.height - 141)

    progress = self.iteration_cnt / (props.step1 + props.step2 + props.step3 +
                                     props.step4)
    bgl.glColor4f(0.7, 0.7, 1.0, 1.0)
    bgl.glVertex2i(10, context.area.height - 130)
    bgl.glVertex2i(int(10 + progress * 40), context.area.height - 130)
    bgl.glVertex2i(int(10 + progress * 40), context.area.height - 140)
    bgl.glVertex2i(10, context.area.height - 140)
    bgl.glEnd()

    bgl.glColor4f(0.0, 0.0, 0.0, 1.0)
    blf.disable(font_id, blf.SHADOW)
 def draw_callback_px(self, context, pos):
     hpos, vpos = 64, 64
     if pos: hpos = pos - 10
     font_id = 0
     blf.enable(font_id, 4)
     blf.position(font_id, hpos, vpos - 25, 0)
     blf.color(font_id, self.scol[0], self.scol[1], self.scol[2],
               self.scol[3])
     blf.size(font_id, 13, 72)
     blf.shadow(font_id, 5, 0, 0, 0, 1)
     blf.shadow_offset(font_id, 1, -1)
     blf.draw(font_id, "[ Quick Origin Move ]")
Пример #22
0
    def __init__(self, font, type, size):

        dir = '\\UI\\Fonts\\'
        font1 = 'EXO2.0-'
        font2 = 'bonn_'
        bold = 'Bold'
        extraBold = 'ExtraBold'
        regular = 'Regular'
        light = 'Light'
        format = ['.otf', '.ttf']

        self.font_info = {
            'font_id': None,
            'font_handler': None,
            'loaded_font': None
        }
        filepath = None
        if font == 'Exo':
            if type == 'Bold':
                filepath = parent[:-10] + dir + font1 + bold + format[0]
                self.font_info['loaded_font'] = filepath
            elif type == 'ExtraBold':
                filepath = parent[:-10] + dir + font1 + extraBold + format[0]
                self.font_info['loaded_font'] = filepath
            elif type == 'Regular':
                filepath = parent[:-10] + dir + font1 + regular + format[0]
                self.font_info['loaded_font'] = filepath
            elif type == 'Light':
                filepath = parent[:-10] + dir + font1 + light + format[0]
                self.font_info['loaded_font'] = filepath

        elif font == 'Bonn':
            if type == 'Bold':
                filepath = parent[:-10] + dir + font2 + bold + format[1]
            elif type == 'ExtraBold':
                print('This font does not have Extra Bold')
                filepath = None
            elif type == 'Regular':
                filepath = parent[:-10] + dir + font2 + regular + format[1]
            elif type == 'Light':
                filepath = parent[:-10] + dir + font2 + light + format[1]

        self.parent = Vector3([0, 0, 0])
        self.position = Vector3([0, 0, 0])
        self.pos_pus_parent = Vector3([
            self.parent.x + self.position.x,
            self.parent.y + self.position.y,
            self.parent.z + self.position.z,
        ])

        self.font_info['font_id'] = blf.load(filepath)
        blf.size(self.font_info['font_id'], size, 72)
        blf.enable(self.font_info['font_id'], 1)
def draw_callback_px(self, context):
    col = self.textcolor
    font_id = 0

    blf.enable(font_id, blf.SHADOW)
    blf.shadow(font_id, 0, 0.0, 0.0, 0.0, 1.0)
    blf.position(font_id, 64, 24, 0)
    blf.size(font_id, 11, 72)

    blf.draw(font_id, self.nearname)

    blf.disable(font_id, blf.SHADOW)
def draw_callback_px(self, context):
    col = self.textcolor
    font_id = 0
    
    blf.enable(font_id, blf.SHADOW)
    blf.shadow(font_id, 0, 0.0, 0.0, 0.0, 1.0)
    blf.position(font_id, 64, 24, 0)
    blf.size(font_id, 11, 72)
    
    blf.draw(font_id, self.nearname)
    
    blf.disable(font_id, blf.SHADOW)
Пример #25
0
    def __render_each_data(context, data):
        sc = context.scene
        # setup rendering region
        for area in bpy.context.screen.areas:
            if area.type == "VIEW_3D":
                break
        else:
            return
        for region in area.regions:
            if region.type == "WINDOW":
                break
        else:
            return
        for space in area.spaces:
            if space.type == "VIEW_3D":
                break
        else:
            return
        loc_on_screen = view3d_utils.location_3d_to_region_2d(
            region,
            space.region_3d,
            data[1])

        rect = get_canvas(context, loc_on_screen, len(str(data[0])), sc.iv_font_size)
        positions = [
            [rect.x0, rect.y0],
            [rect.x0, rect.y1],
            [rect.x1, rect.y1],
            [rect.x1, rect.y0]
        ]

        # render box
        bgl.glEnable(bgl.GL_BLEND)
        bgl.glBegin(bgl.GL_QUADS)
        box_color_r, box_color_g, box_color_b, box_color_a = sc.iv_box_color
        bgl.glColor4f(box_color_r, box_color_g, box_color_b, box_color_a)
        for (v1, v2) in positions:
            bgl.glVertex2f(v1, v2)
        bgl.glEnd()

        # render index
        font_size = sc.iv_font_size
        blf.size(0, font_size, 72)
        blf.enable(0, blf.SHADOW)
        blf.shadow_offset(0, 1, -1)
        blf.shadow(0, 5, 0.0, 0.0, 0.0, 0.0)
        blf.position(0, rect.x0 + (rect.x1 - rect.x0) * 0.18, rect.y0 + (rect.y1 - rect.y0) * 0.24, 0)
        text_color_r, text_color_g, text_color_b, text_color_a = sc.iv_text_color
        bgl.glColor4f(text_color_r, text_color_g, text_color_b, text_color_a)
        blf.draw(0, str(data[0]))
        blf.blur(0, 0)
        blf.disable(0, blf.SHADOW)
Пример #26
0
def draw_text(text: str, font: int, size: int, x: int, y: int, horizontal: str,
              vertical: str, shadow: bool):
    '''
    Draw two aligned columns of text.

    Args:
        text: List of tuples of two strings.
        font: ID returned by blf.load or 0.
        size: How large the font should be.
        x, y: Pixel on the active area.
        horizontal: 'LEFT', 'CENTER', or 'RIGHT'.
        vertical: 'BOTTOM', 'CENTER', or 'TOP'.
        shadow: Whether to add a dropshadow.
    '''

    blf.size(font, size, 72)
    widths_l = [blf.dimensions(font, line[0])[0] for line in text]
    widths_r = [blf.dimensions(font, line[1])[0] for line in text]

    height = blf.dimensions(font, 'A')[1] * 2
    space = height * 0.5
    y += height * 0.25

    if horizontal == 'LEFT':
        x += max(widths_l) + space
    elif horizontal == 'RIGHT':
        x -= max(widths_r) + space

    if vertical == 'BOTTOM':
        y += height * len(text)
    elif vertical == 'CENTER':
        y += height * len(text) * 0.5

    if shadow:
        blf.enable(font, blf.SHADOW)
        blf.shadow(font, 5, 0, 0, 0, 1)
        blf.shadow_offset(font, 1, -1)

    for index, line in enumerate(text):
        offset = (index + 2) * height

        left, right = line
        width = widths_l[index]

        blf.position(font, x - width - space, y - offset, 0)
        blf.draw(font, left)

        blf.position(font, x + space, y - offset, 0)
        blf.draw(font, right)

    if shadow:
        blf.disable(font, blf.SHADOW)
    def __render_each_data(context, data):
        sc = context.scene
        # setup rendering region
        for area in bpy.context.screen.areas:
            if area.type == "VIEW_3D":
                break
        else:
            return
        for region in area.regions:
            if region.type == "WINDOW":
                break
        else:
            return
        for space in area.spaces:
            if space.type == "VIEW_3D":
                break
        else:
            return
        loc_on_screen = view3d_utils.location_3d_to_region_2d(
            region,
            space.region_3d,
            data[1])

        rect = get_canvas(context, loc_on_screen, len(str(data[0])), sc.iv_font_size)
        positions = [
            [rect.x0, rect.y0],
            [rect.x0, rect.y1],
            [rect.x1, rect.y1],
            [rect.x1, rect.y0]
            ]

        # render box
        bgl.glEnable(bgl.GL_BLEND)
        bgl.glBegin(bgl.GL_QUADS)
        box_color_r, box_color_g, box_color_b, box_color_a = sc.iv_box_color
        bgl.glColor4f(box_color_r, box_color_g, box_color_b, box_color_a)
        for (v1, v2) in positions:
            bgl.glVertex2f(v1, v2)
        bgl.glEnd()

        # render index
        font_size = sc.iv_font_size
        blf.size(0, font_size, 72)
        blf.enable(0, blf.SHADOW)
        blf.shadow_offset(0, 1, -1)
        blf.shadow(0, 5, 0.0, 0.0, 0.0, 0.0)
        blf.position(0, rect.x0 + (rect.x1 - rect.x0) * 0.18, rect.y0 + (rect.y1 - rect.y0) * 0.24, 0)
        text_color_r, text_color_g, text_color_b, text_color_a = sc.iv_text_color
        bgl.glColor4f(text_color_r, text_color_g, text_color_b, text_color_a)
        blf.draw(0, str(data[0]))
        blf.blur(0, 0)
        blf.disable(0, blf.SHADOW)
Пример #28
0
def draw_text(font_id, location, text, color):

    x, y = location
    r, g, b = color
    blf.position(font_id, x, y, 0)
    level = 5 # 3, 5 or 0

    blf.color(font_id, r, g, b, 1.0)
    blf.enable(font_id, blf.SHADOW)
    blf.shadow(font_id, level, 0, 0, 0, 1)
    blf.shadow_offset(font_id, 1, -1)
    blf.draw(font_id, text)
    blf.disable(font_id, blf.SHADOW)
Пример #29
0
def draw_text(text, font_id, color, shadow=False, color_shadow=None):
    blf.enable(font_id, blf.SHADOW)

    # Draw shadow.
    if shadow:
        blf.shadow_offset(font_id, 3, -3)
        blf.shadow(font_id, 5, *color_shadow, 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)
Пример #30
0
def _denoiser_help_text(context):
    if not context.scene.luxcore.denoiser.enabled:
        return
    current_image = context.space_data.image
    if current_image is None or current_image.type != "RENDER_RESULT":
        return

    # Only show the help text if the toolshelf is not visible
    for area in context.screen.areas:
        if area.type == 'IMAGE_EDITOR':
            for space in area.spaces:
                if space == context.space_data:
                    # It is the current image editor
                    for region in area.regions:
                        # Note: when the tool region is hidden, it has width == 1
                        if region.type == "TOOLS" and region.width > 1:
                            # Toolshelf is visible, do not show the help text
                            return

    image_user = context.space_data.image_user
    layer_index = image_user.multilayer_layer
    render_layers = context.scene.render.layers

    if layer_index >= len(render_layers):
        return

    render_layer = render_layers[layer_index]

    # Combined is index 0, depth is index 1 if enabled, denoised pass is right behind them
    denoised_pass_index = 2 if render_layer.luxcore.aovs.depth else 1

    if image_user.multilayer_pass == denoised_pass_index:
        # From https://github.com/sftd/blender-addons-contrib/blob/master/render_time.py
        font_id = 0  # XXX, need to find out how best to get this. [sic]
        ui_scale = context.user_preferences.view.ui_scale
        dpi = round(72 * ui_scale)

        pos_y = 45 * ui_scale
        blf.position(font_id, 15, pos_y, 0)
        blf.size(font_id, 14, dpi)
        blf.enable(font_id, blf.SHADOW)
        blf.shadow(font_id, 5, 0.0, 0.0, 0.0, 1.0)

        blf.draw(font_id,
                 '← The denoiser controls are in the "LuxCore" category')
        pos_y -= 20 * ui_scale
        blf.position(font_id, 15, pos_y, 0)
        blf.draw(font_id, 'in the tool shelf, (press T)')

        # restore defaults
        blf.disable(font_id, blf.SHADOW)
Пример #31
0
    def draw(self):
        pr = prefs().overlay

        if pr.shadow:
            a = 1
            blf.enable(0, blf.SHADOW)
            blf.shadow_offset(0, 1, -1)
            blf.shadow(0, 5, 0.0, 0.0, 0.0, a * 0.4 * self.alpha)

        for p in self.painters:
            p.draw()

        if pr.shadow:
            blf.disable(0, blf.SHADOW)
Пример #32
0
 def text_size(self, context):
     """
         overall on-screen size in pixels
     """
     dpi, font_id = context.user_preferences.system.dpi, 0
     if self.angle != 0:
         blf.enable(font_id, blf.ROTATION)
         blf.rotation(font_id, self.angle)
     blf.aspect(font_id, 1.0)
     blf.size(font_id, self.font_size, dpi)
     x, y = blf.dimensions(font_id, self.text)
     if self.angle != 0:
         blf.disable(font_id, blf.ROTATION)
     return Vector((x, y))
Пример #33
0
 def draw(self, context, render=False):
     self.render = render
     x, y = self.position_2d_from_coord(context, self.pts[0], render)
     # dirty fast assignment
     dpi, font_id = context.user_preferences.system.dpi, 0
     bgl.glColor4f(*self.colour)
     if self.angle != 0:
         blf.enable(font_id, blf.ROTATION)
         blf.rotation(font_id, self.angle)
     blf.size(font_id, self.font_size, dpi)
     blf.position(font_id, x, y, 0)
     blf.draw(font_id, self.text)
     if self.angle != 0:
         blf.disable(font_id, blf.ROTATION)
Пример #34
0
    def draw_clipped(self):
        blf.size(self.textData.font_id, self.textData.fontSize, 72)

        blf.enable(self.textData.font_id, blf.CLIPPING)

        blf.clipping(self.textData.font_id, *self.clipRect._clipRect)

        if self.textData.color:
            blf.color(self.textData.font_id, *self.textData.color)

        blf.position(self.textData.font_id, self.xPos, self.yPos, 0)
        blf.draw(self.textData.font_id, self.text)

        blf.disable(self.textData.font_id, blf.CLIPPING)
Пример #35
0
def draw_callback_px(self, context):
    addon_prefs = context.preferences.addons["rotate_an_hdri"].preferences
    if addon_prefs.show_angle:
        r, g, b, a = addon_prefs.text_color
        angle = get_hdri_rotation_angle(context)
        width = context.area.width
        font_id = 0
        blf.enable(font_id, blf.SHADOW)
        blf.shadow(font_id, 3, 0, 0, 0, 0.7)
        blf.shadow_offset(font_id, 2, -2)
        blf.color(font_id, r, g, b, a)
        blf.position(font_id, width / 2, 60, 0)
        blf.size(font_id, 30, addon_prefs.text_size)
        blf.draw(font_id, f"{(math.degrees(angle)):.1f}°")
Пример #36
0
    def _drawDisplayMessage(self, context):
        """
        Message telling user to move the window the HMD display
        """
        from bgl import glColor4f

        window = context.window
        width = window.width
        height = window.height

        glColor4f(1.0, 1.0, 1.0, 1.0)
        font_id = 0

        # draw some text
        x = int(0.1 * width)
        y = int(0.5 * height)
        font_size = int(width * 0.035)
        line_gap = int(font_size * 1.5)

        from blf import (
                SHADOW,
                enable,
                shadow,
                shadow_offset,
                position,
                size,
                draw,
                disable,
                )

        enable(font_id, SHADOW)
        shadow(font_id, 5, 0.0, 0.0, 0.0, 1.0)
        shadow_offset(font_id, -2, -2)
        size(font_id, font_size, 72)

        if self._is_mac:
            position(font_id, x, y + line_gap, 0)
            draw(font_id, "1. Move this window to the external HMD display")
            position(font_id, x, y, 0)
            draw(font_id, "2. Set this window to fullscreen (Alt + F11)")
            position(font_id, x, y - line_gap, 0)
            draw(font_id, "3. Select \"Start\" in the main window")
        else:
            position(font_id, x, y, 0)
            draw(font_id, "1. Move this window to the external HMD display")
            position(font_id, x, y - line_gap, 0)
            draw(font_id, "2. Select \"Start\" in the main window")

        disable(font_id, SHADOW)
Пример #37
0
    def _drawDisplayMessage(self, context):
        """
        Message telling user to move the window the HMD display
        """
        from bgl import glColor4f

        window = context.window
        width = window.width
        height = window.height

        glColor4f(1.0, 1.0, 1.0, 1.0)
        font_id = 0

        # draw some text
        x = int(0.1 * width)
        y = int(0.5 * height)
        font_size = int(width * 0.035)
        line_gap = int(font_size * 1.5)

        from blf import (
            SHADOW,
            enable,
            shadow,
            shadow_offset,
            position,
            size,
            draw,
            disable,
        )

        enable(font_id, SHADOW)
        shadow(font_id, 5, 0.0, 0.0, 0.0, 1.0)
        shadow_offset(font_id, -2, -2)
        size(font_id, font_size, 72)

        if self._is_mac:
            position(font_id, x, y + line_gap, 0)
            draw(font_id, "1. Move this window to the external HMD display")
            position(font_id, x, y, 0)
            draw(font_id, "2. Set this window to fullscreen (Alt + F11)")
            position(font_id, x, y - line_gap, 0)
            draw(font_id, "3. Select \"Start\" in the main window")
        else:
            position(font_id, x, y, 0)
            draw(font_id, "1. Move this window to the external HMD display")
            position(font_id, x, y - line_gap, 0)
            draw(font_id, "2. Select \"Start\" in the main window")

        disable(font_id, SHADOW)
Пример #38
0
    def draw(self, context):
        w = context.region.width
        h = context.region.height

        # Draw text area that PRMan is running.
        pos_x = w / 2 - 100
        pos_y = 20
        blf.enable(0, blf.SHADOW)
        blf.shadow_offset(0, 1, -1)
        blf.shadow(0, 5, 0.0, 0.0, 0.0, 0.8)
        blf.size(0, 32, 36)
        blf.position(0, pos_x, pos_y, 0)
        bgl.glColor4f(1.0, 0.0, 0.0, 1.0)
        blf.draw(0, "%s" % ('PRMan Interactive Mode Running'))
        blf.disable(0, blf.SHADOW)
Пример #39
0
    def draw(self, context, render=False):

        # print("draw_text %s %s" % (self.text, type(self).__name__))
        self.render = render
        x, y = self.position_2d_from_coord(context, self.pts[0], render)
        # dirty fast assignment
        dpi, font_id = context.user_preferences.system.dpi, 0
        bgl.glColor4f(*self.colour)
        if self.angle != 0:
            blf.enable(font_id, blf.ROTATION)
            blf.rotation(font_id, self.angle)
        blf.size(font_id, self.font_size, dpi)
        blf.position(font_id, x, y, 0)
        blf.draw(font_id, self.text)
        if self.angle != 0:
            blf.disable(font_id, blf.ROTATION)
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)
Пример #41
0
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)

    blf.draw(font_id, "Total render time " + str(timedelta(seconds = timer["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: " + str(timedelta(seconds = (timer["average"] * (scene.frame_end - scene.frame_current)))))

    # restore defaults
    blf.disable(font_id, blf.SHADOW)
def draw_last_operator(context, pos_x, pos_y):

    wm = context.window_manager
    sc = context.scene
    font_color_r, font_color_g, font_color_b, font_color_alpha = sc.screencast_keys_text_color
    pos_x, pos_y = getDisplayLocation(context)

    if wm.operators:
        last_operator = wm.operators[-1].bl_label

        blf.enable(0, blf.SHADOW)
        blf.shadow_offset(0, 1, -1)
        blf.shadow(0, 5, 0.0, 0.0, 0.0, 0.8)
        blf.size(0, sc.screencast_keys_font_size, 36)
        blf.position(0, pos_x - 14, pos_y - 30, 0)
        bgl.glColor4f(font_color_r, font_color_g, font_color_b, font_color_alpha * 0.8)
        blf.draw(0, "Last: %s" % (last_operator))
        blf.disable(0, blf.SHADOW)
Пример #43
0
    def __render(self, context):
        # リージョン幅を取得するため、描画先のリージョンを得る
        region = RenderText.__get_region(context, 'VIEW_3D', 'WINDOW')

        # 描画先のリージョンへテキストを描画
        if region is not None:
            # 影の効果を設定
            blf.shadow(0, 3, 0.0, 1.0, 0.0, 0.5)
            # 影の位置を設定
            blf.shadow_offset(0, 2, -2)
            # 影の効果を有効化
            blf.enable(0, blf.SHADOW)
            RenderText.__render_text(
                40, 40, region.height - 120, "Hello Blender world!!"
            )
            # 影の効果を無効化
            blf.disable(0, blf.SHADOW)
            RenderText.__render_text(
                30, 40, region.height - 180, "Suzanne on your lap"
            )
Пример #44
0
def write_interaction_status():
    """
    Write the interaction status on Screen
    The status is stored in a property
    """
    hand = objects["Hand_Grab.R"]

    # OpenGL setup
    bgl.glMatrixMode(bgl.GL_PROJECTION)
    bgl.glLoadIdentity()
    bgl.gluOrtho2D(0, windowWidth, 0, windowHeight)
    bgl.glMatrixMode(bgl.GL_MODELVIEW)
    bgl.glLoadIdentity()

    blf.size(font_id, int(windowHeight * 0.04), 72)
    # draw a black shadow around the text
    blf.enable(font_id, blf.SHADOW)
    blf.shadow(font_id, 5, 0.0, 0.0, 0.0, 1.0)
    blf.position(font_id, windowWidth * 0.4, windowHeight * 0.4, 0)
    blf.draw(font_id, hand["Status"])
Пример #45
0
    def draw(self, context, render=False):

        # print("draw_text %s %s" % (self.text, type(self).__name__))
        self.render = render
        p = self.position_2d_from_coord(context, self.pts[0], render)

        # dirty fast assignment
        dpi, font_id = context.preferences.system.dpi, 0

        # self.cbuff[0:4] = self.colour

        # bgl.glEnableClientState(bgl.GL_COLOR_ARRAY)
        # bgl.glColorPointer(4, bgl.GL_FLOAT, 0, self.cbuff)
        blf.color(0, *self.colour)
        if self.angle != 0:
            blf.enable(font_id, blf.ROTATION)
            blf.rotation(font_id, self.angle)
        blf.size(font_id, self.font_size, dpi)
        blf.position(font_id, p.x, p.y, 0)
        blf.draw(font_id, self.text)
        if self.angle != 0:
            blf.disable(font_id, blf.ROTATION)
Пример #46
0
def write():
    """
    Write the name of all active objects on Screen
    """
    # OpenGL setup
    bgl.glMatrixMode(bgl.GL_PROJECTION)
    bgl.glLoadIdentity()
    bgl.gluOrtho2D(0, windowWidth, 0, windowHeight)
    bgl.glMatrixMode(bgl.GL_MODELVIEW)
    bgl.glLoadIdentity()
    
    cam = scene.active_camera

    for obj in passive_objects.active_objects():
        # test if the object is in the view frustum
        if cam.pointInsideFrustum(obj.worldPosition):
            pos = cam.getScreenPosition(obj)
    
            blf.size(font_id, int(windowWidth * 0.02), 72)
            # draw a black shadow to increase contrast with white parts
            blf.enable(font_id, blf.SHADOW)
            blf.shadow(font_id, 5, 0.0, 0.0, 0.0, 1.0)
            blf.position(font_id, pos[0]*windowWidth, (1 - pos[1])*windowHeight,0)
            blf.draw(font_id, obj.name)
Пример #47
0
def write():
    """write on screen"""
    width = render.getWindowWidth()
    height = render.getWindowHeight()

    # OpenGL setup
    bgl.glMatrixMode(bgl.GL_PROJECTION)
    bgl.glLoadIdentity()
    bgl.gluOrtho2D(0, width, 0, height)
    bgl.glMatrixMode(bgl.GL_MODELVIEW)
    bgl.glLoadIdentity()

    # BLF drawing routine
    blf.size(font_id, height//40, 72)
    data = parse_file.read_file()
    data = data.splitlines()
    linePosition = height * 0.8
    for str in data:
        str_len = len(str)
        blf.position(font_id, (width * 0.05), linePosition, 0)
        blf.enable(font_id, blf.SHADOW)
        blf.shadow(font_id, 0, 1.0, 0.2, 0.0, 1.0)
        blf.draw(font_id,str)
        linePosition -= height * 0.05
Пример #48
0
def display_instructions(region, rv3d, instruct, keys_aff, keys_nav, keys_neg):

    rw = region.width
    rh = region.height
    print('rw, rh', rw, rh)

    expand = False
    crop = False

    len_aff_max = rw - 140
    len_aff = len(keys_aff) * 5
    len_neg = len(keys_neg) * 5
    len_ins = len(instruct) * 18
    if len_aff > len_aff_max: expand = True

    rw_min = 480
    rh_min = 280
    if rw < rw_min or rh < rh_min: crop = True


    version = '020'
    font_id = 0

    keys_aff_1 = copy.deepcopy(keys_aff)
    keys_aff_2 = ' '
    if expand:
        keys_aff_1 = ''
        keys_aff_2 = ''
        print('len(keys_aff)', len(keys_aff))
        stop = 0
        for i in range (0, len(keys_aff)-1):
            #print(keys_aff[i])
            if keys_aff[i] == ',' and i * 5 <= len_aff_max and i > stop:
                stop = i
        print ('stop', stop)
        for i in range(0, stop + 1):
            keys_aff_1 = keys_aff_1 + keys_aff[i]
        for i in range(stop + 2, len(keys_aff)):
            keys_aff_2 = keys_aff_2 + keys_aff[i]
        print(keys_aff_1)
        print(keys_aff_2)

    field_keys_y = 46
    field_keys_x = 80
    field_keys_aff_1 = [[field_keys_x, field_keys_y + 21], [field_keys_x, field_keys_y + 39], [rw - int(field_keys_x / 2), field_keys_y + 39], [rw - int(field_keys_x / 2), field_keys_y + 21]]
    field_keys_aff_2 = copy.deepcopy(field_keys_aff_1)
    field_keys_neg = [[field_keys_x, field_keys_y], [field_keys_x, field_keys_y + 18], [rw - field_keys_x / 2, field_keys_y + 18], [rw - field_keys_x / 2, field_keys_y]]
    if expand:
        field_keys_aff_2 = copy.deepcopy(field_keys_neg)
        field_keys_neg = [[field_keys_x, field_keys_y - 21], [field_keys_x, field_keys_y - 3], [rw - field_keys_x / 2, field_keys_y - 3], [rw - field_keys_x / 2, field_keys_y - 21]]

    size_font_np = 25
    size_font_instruct = 21
    size_font_keys = 11
    len_np_ins = len_ins + int(size_font_np * 2.1)

    pos_font_np_x = (rw - (len_np_ins / 2)) / 2
    pos_font_np_y = 150
    if crop: pos_font_np_y = 75
    pos_font_instruct_x = pos_font_np_x + int(size_font_np * 2.1)
    pos_font_instruct_y = pos_font_np_y + 4
    pos_font_keys_aff_1_x = field_keys_x + 8
    pos_font_keys_aff_1_y = field_keys_y + 26
    pos_font_keys_aff_2_x = copy.deepcopy(pos_font_keys_aff_1_x)
    pos_font_keys_aff_2_y = copy.deepcopy(pos_font_keys_aff_1_y)
    pos_font_keys_nav_x = field_keys_x + 8
    pos_font_keys_nav_y = field_keys_y + 5
    pos_font_keys_neg_x = rw - 52 - len_neg
    print ('len_neg', len_neg)
    print ('pos_font_keys_neg_x', pos_font_keys_neg_x)
    pos_font_keys_neg_y = field_keys_y + 5
    if expand:
        pos_font_keys_aff_2_x = field_keys_x + 8
        pos_font_keys_aff_2_y = field_keys_y + 5
        pos_font_keys_nav_x = field_keys_x + 8
        pos_font_keys_nav_y = field_keys_y - 16
        pos_font_keys_neg_x = rw - 52 - len_neg
        pos_font_keys_neg_y = field_keys_y - 16

    col_font_np = addon_settings_graph()['col_font_np']
    col_font_instruct_main = addon_settings_graph()['col_font_instruct_main']
    col_font_instruct_shadow = addon_settings_graph()['col_font_instruct_shadow']
    col_font_keys = addon_settings_graph()['col_font_keys']
    col_field_keys_aff = addon_settings_graph()['col_field_keys_aff']
    col_field_keys_neg = addon_settings_graph()['col_field_keys_neg']



    # instructions - NP:

    bgl.glColor4f(*col_font_np)
    blf.size(font_id, size_font_np, 72)
    blf.position(font_id, pos_font_np_x, pos_font_np_y, 0)
    blf.draw(font_id, 'NP')

    blf.enable(font_id, ROTATION)
    ang = radians(90)
    blf.size(font_id, int(size_font_np / 2.2), 72)
    blf.rotation(font_id, ang)
    blf.position(font_id, pos_font_np_x + int(size_font_np * 1.72) , pos_font_np_y - 2, 0)
    blf.draw(font_id, version)
    blf.disable(font_id, ROTATION)

    # instructions - instruct:

    bgl.glColor4f(*col_font_instruct_shadow)
    blf.position(font_id, pos_font_instruct_x + 1, pos_font_instruct_y - 1, 0)
    blf.size(font_id, size_font_instruct, 72)
    blf.draw(font_id, instruct)

    bgl.glColor4f(*col_font_instruct_main)
    blf.position(font_id, pos_font_instruct_x, pos_font_instruct_y, 0)
    blf.size(font_id, size_font_instruct, 72)
    blf.draw(font_id, instruct)

    bgl.glDisable(bgl.GL_BLEND)

    # instructions - keys - backdrop fields:

    bgl.glEnable(bgl.GL_BLEND)

    if crop == False:

        bgl.glColor4f(*col_field_keys_aff)
        bgl.glBegin(bgl.GL_TRIANGLE_FAN)
        for co in field_keys_aff_1:
            bgl.glVertex2f(*co)
        bgl.glEnd()

        bgl.glColor4f(*col_field_keys_aff)
        bgl.glBegin(bgl.GL_TRIANGLE_FAN)
        for co in field_keys_aff_2:
            bgl.glVertex2f(*co)
        bgl.glEnd()

        bgl.glColor4f(*col_field_keys_neg)
        bgl.glBegin(bgl.GL_TRIANGLE_FAN)
        for co in field_keys_neg:
            bgl.glVertex2f(*co)
        bgl.glEnd()


        # instructions - keys - writing:

        bgl.glColor4f(*col_font_keys)
        blf.size(font_id, size_font_keys, 72)

        blf.position(font_id, pos_font_keys_aff_1_x, pos_font_keys_aff_1_y, 0)
        blf.draw(font_id, keys_aff_1)

        blf.position(font_id, pos_font_keys_aff_2_x, pos_font_keys_aff_2_y, 0)
        blf.draw(font_id, keys_aff_2)

        blf.position(font_id, pos_font_keys_nav_x, pos_font_keys_nav_y, 0)
        blf.draw(font_id, keys_nav)

        blf.position(font_id, pos_font_keys_neg_x, pos_font_keys_neg_y, 0)
        blf.draw(font_id, keys_neg)
Пример #49
0
def draw_callback_px(self, context):
    """Draws Code Editors Minimap and indentation marks"""

    def draw_line(origin, length, thickness, vertical=False):
        """Drawing lines with polys, its faster"""
        x = (origin[0] + thickness) if vertical else (origin[0] + length)
        y = (origin[1] + length) if vertical else (origin[1] + thickness)
        bgl.glBegin(bgl.GL_QUADS)
        for v1, v2 in [origin, (x, origin[1]), (x, y), (origin[0], y)]:
            bgl.glVertex2i(v1, v2)
        bgl.glEnd()
        return

    # abort if another text editor
    if self.area == context.area and self.window == context.window:
        bgl.glEnable(bgl.GL_BLEND)
    else:
        return

    start = time.clock()

    # init params
    font_id = 0
    self.width = next(region.width for region in context.area.regions if region.type == "WINDOW")
    self.height = next(region.height for region in context.area.regions if region.type == "WINDOW")
    dpi_r = context.user_preferences.system.dpi / 72.0
    self.left_edge = self.width - round(dpi_r * (self.width + 5 * self.minimap_width) / 10.0)
    self.right_edge = self.width - round(dpi_r * 15)
    self.opacity = min(max(0, (self.width - self.min_width) / 100.0), 1)

    # compute character dimensions
    mcw = dpi_r * self.minimap_symbol_width  # minimap char width
    mlh = round(dpi_r * self.minimap_line_height)  # minimap line height
    fs = context.space_data.font_size
    cw = round(dpi_r * round(2 + 0.6 * (fs - 4)))  # char width
    ch = round(dpi_r * round(2 + 1.3 * (fs - 2) + ((fs % 10) == 0)))  # char height

    # panel background box
    self.tab_width = round(dpi_r * 25) if (self.tabs and len(bpy.data.texts) > 1) else 0
    bgl.glColor4f(self.background.r, self.background.g, self.background.b, (1 - self.bg_opacity) * self.opacity)
    bgl.glBegin(bgl.GL_QUADS)
    for x, y in [
        (self.left_edge - self.tab_width, self.height),
        (self.right_edge, self.height),
        (self.right_edge, 0),
        (self.left_edge - self.tab_width, 0),
    ]:
        bgl.glVertex2i(x, y)
    bgl.glEnd()

    # line numbers background
    space = context.space_data
    if space.text:
        lines = len(space.text.lines)
        lines_digits = len(str(lines)) if space.show_line_numbers else 0
        self.line_bar_width = int(dpi_r * 5) + cw * (lines_digits)
        bgl.glColor4f(self.background.r, self.background.g, self.background.b, 1)
        bgl.glBegin(bgl.GL_QUADS)
        for x, y in [(0, self.height), (self.line_bar_width, self.height), (self.line_bar_width, 0), (0, 0)]:
            bgl.glVertex2i(x, y)
        bgl.glEnd()
        # shadow
        bgl.glLineWidth(1.0 * dpi_r)
        for id, intensity in enumerate([0.2, 0.1, 0.07, 0.05, 0.03, 0.02, 0.01]):
            bgl.glColor4f(0.0, 0.0, 0.0, intensity)
            bgl.glBegin(bgl.GL_LINE_STRIP)
            for x, y in [(self.line_bar_width + id, 0), (self.line_bar_width + id, self.height)]:
                bgl.glVertex2i(x, y)
            bgl.glEnd()

    # minimap shadow
    for id, intensity in enumerate([0.2, 0.1, 0.07, 0.05, 0.03, 0.02, 0.01]):
        bgl.glColor4f(0.0, 0.0, 0.0, intensity * self.opacity)
        bgl.glBegin(bgl.GL_LINE_STRIP)
        for x, y in [(self.left_edge - id - self.tab_width, 0), (self.left_edge - id - self.tab_width, self.height)]:
            bgl.glVertex2i(x, y)
        bgl.glEnd()

    # divider
    if self.tab_width:
        bgl.glColor4f(0.0, 0.0, 0.0, 0.2 * self.opacity)
        bgl.glBegin(bgl.GL_LINE_STRIP)
        for x, y in [(self.left_edge, 0), (self.left_edge, self.height)]:
            bgl.glVertex2i(x, y)
        bgl.glEnd()

    # if there is text in window
    if space.text and self.opacity:

        # minimap horizontal sliding based on text block length
        max_slide = max(0, mlh * (lines + self.height / ch) - self.height)
        self.slide = int(max_slide * space.top / lines)
        minimap_top_line = int(self.slide / mlh)
        minimap_bot_line = int((self.height + self.slide) / mlh)

        # draw minimap visible box
        if self.in_minimap:
            bgl.glColor4f(1.0, 1.0, 1.0, 0.1 * self.opacity)
        else:
            bgl.glColor4f(1.0, 1.0, 1.0, 0.07 * self.opacity)
        bgl.glBegin(bgl.GL_QUADS)
        for x, y in [
            (self.left_edge, self.height - mlh * space.top + self.slide),
            (self.right_edge, self.height - mlh * space.top + self.slide),
            (self.right_edge, self.height - mlh * (space.top + space.visible_lines) + self.slide),
            (self.left_edge, self.height - mlh * (space.top + space.visible_lines) + self.slide),
        ]:
            bgl.glVertex2i(x, y)
        bgl.glEnd()

        # draw minimap code
        for segment in self.segments[:-1]:
            bgl.glColor4f(segment["col"][0], segment["col"][1], segment["col"][2], 0.4 * self.opacity)
            for id, element in enumerate(segment["elements"][minimap_top_line:minimap_bot_line]):
                loc_y = mlh * (id + minimap_top_line + 3) - self.slide
                for sub_element in element:
                    draw_line(
                        (self.left_edge + int(mcw * (sub_element[0] + 4)), self.height - loc_y),
                        int(mcw * (sub_element[1] - sub_element[0])),
                        int(0.5 * mlh),
                    )

        # minimap code marks
        bgl.glColor4f(
            self.segments[-2]["col"][0],
            self.segments[-2]["col"][1],
            self.segments[-2]["col"][2],
            0.3 * self.block_trans * self.opacity,
        )
        for id, element in enumerate(self.segments[-2]["elements"]):
            for sub_element in element:
                if sub_element[2] >= space.top or id < space.top + space.visible_lines:
                    draw_line(
                        (self.left_edge + int(mcw * (sub_element[0] + 4)), self.height - mlh * (id + 3) + self.slide),
                        -int(mlh * (sub_element[2] - id - 1)),
                        int(0.5 * mlh),
                        True,
                    )

    # draw dotted indentation marks
    bgl.glLineWidth(1.0 * dpi_r)
    if space.text:
        bgl.glColor4f(
            self.segments[0]["col"][0], self.segments[0]["col"][1], self.segments[0]["col"][2], self.indent_trans
        )
        for id, element in enumerate(self.segments[-1]["elements"][space.top : space.top + space.visible_lines]):
            loc_y = id
            for sub_element in element:
                draw_line(
                    (int(dpi_r * 10) + cw * (lines_digits + sub_element[0] + 4), self.height - ch * (loc_y)),
                    -ch,
                    int(1 * dpi_r),
                    True,
                )

        # draw code block marks
        bgl.glColor4f(
            self.segments[-2]["col"][0], self.segments[-2]["col"][1], self.segments[-2]["col"][2], self.block_trans
        )
        for id, element in enumerate(self.segments[-2]["elements"]):
            for sub_element in element:
                if sub_element[2] >= space.top or id < space.top + space.visible_lines:
                    bgl.glBegin(bgl.GL_LINE_STRIP)
                    bgl.glVertex2i(
                        int(dpi_r * 10 + cw * (lines_digits + sub_element[0])), self.height - ch * (id + 1 - space.top)
                    )
                    bgl.glVertex2i(
                        int(dpi_r * 10 + cw * (lines_digits + sub_element[0])),
                        self.height - int(ch * (sub_element[2] - space.top)),
                    )
                    bgl.glVertex2i(
                        int(dpi_r * 10 + cw * (lines_digits + sub_element[0] + 1)),
                        self.height - int(ch * (sub_element[2] - space.top)),
                    )
                    bgl.glEnd()

    # tab dividers
    if self.tab_width and self.opacity:
        self.tab_height = min(200, int(self.height / len(bpy.data.texts)))
        y_loc = self.height - 5
        for text in bpy.data.texts:
            # tab selection
            if text.name == self.in_tab:
                bgl.glColor4f(1.0, 1.0, 1.0, 0.05 * self.opacity)
                bgl.glBegin(bgl.GL_QUADS)
                for x, y in [
                    (self.left_edge - self.tab_width, y_loc),
                    (self.left_edge, y_loc),
                    (self.left_edge, y_loc - self.tab_height),
                    (self.left_edge - self.tab_width, y_loc - self.tab_height),
                ]:
                    bgl.glVertex2i(x, y)
                bgl.glEnd()
            # tab active
            if context.space_data.text and text.name == context.space_data.text.name:
                bgl.glColor4f(1.0, 1.0, 1.0, 0.05 * self.opacity)
                bgl.glBegin(bgl.GL_QUADS)
                for x, y in [
                    (self.left_edge - self.tab_width, y_loc),
                    (self.left_edge, y_loc),
                    (self.left_edge, y_loc - self.tab_height),
                    (self.left_edge - self.tab_width, y_loc - self.tab_height),
                ]:
                    bgl.glVertex2i(x, y)
                bgl.glEnd()
            bgl.glColor4f(0.0, 0.0, 0.0, 0.2 * self.opacity)
            y_loc -= self.tab_height
            bgl.glBegin(bgl.GL_LINE_STRIP)
            for x, y in [(self.left_edge - self.tab_width, y_loc), (self.left_edge, y_loc)]:
                bgl.glVertex2i(x, y)
            bgl.glEnd()

    # draw fps
    #    bgl.glColor4f(1, 1, 1, 0.2)
    #    blf.size(font_id, fs, int(dpi_r*72))
    #    blf.position(font_id, self.left_edge-50, 5, 0)
    #    blf.draw(font_id, str(round(1/(time.clock() - start),3)))

    # draw line numbers
    if space.text:
        bgl.glColor4f(self.segments[0]["col"][0], self.segments[0]["col"][1], self.segments[0]["col"][2], 0.5)
        for id in range(space.top, min(space.top + space.visible_lines + 1, lines + 1)):
            if self.in_line_bar and self.segments[-2]["elements"][id - 1]:
                bgl.glColor4f(self.segments[-2]["col"][0], self.segments[-2]["col"][1], self.segments[-2]["col"][2], 1)
                blf.position(
                    font_id, 2 + int(0.5 * cw * (len(str(lines)) - 1)), self.height - ch * (id - space.top) + 3, 0
                )
                # blf.draw(font_id, '→')
                blf.draw(font_id, "↓")
                bgl.glColor4f(self.segments[0]["col"][0], self.segments[0]["col"][1], self.segments[0]["col"][2], 0.5)
            else:
                blf.position(
                    font_id,
                    2 + int(0.5 * cw * (len(str(lines)) - len(str(id)))),
                    self.height - ch * (id - space.top) + 3,
                    0,
                )
                blf.draw(font_id, str(id))

    # draw file names
    if self.tab_width:
        blf.enable(font_id, blf.ROTATION)
        blf.rotation(font_id, 1.570796)
        y_loc = self.height
        for text in bpy.data.texts:
            text_max_length = max(2, int((self.tab_height - 40) / cw))
            name = text.name[:text_max_length]
            if text_max_length < len(text.name):
                name += "..."
            bgl.glColor4f(
                self.segments[0]["col"][0],
                self.segments[0]["col"][1],
                self.segments[0]["col"][2],
                (0.7 if text.name == self.in_tab else 0.4) * self.opacity,
            )
            blf.position(
                font_id,
                self.left_edge - round((self.tab_width - ch) / 2.0) - 5,
                round(y_loc - (self.tab_height / 2) - cw * len(name) / 2),
                0,
            )
            blf.draw(font_id, name)
            y_loc -= self.tab_height

    # restore opengl defaults
    bgl.glColor4f(0, 0, 0, 1)
    bgl.glLineWidth(1.0)
    bgl.glDisable(bgl.GL_BLEND)
    blf.disable(font_id, blf.ROTATION)
    return
Пример #50
0
def _draw_3dview_report(region):
    """Draws reports in 3d views.

    :param region: region of 3D viewport
    :type region: bpy.types.Region
    """
    if _Show3DViewReportOperator.has_lines():

        blf.size(0, 15, 72)
        pos = region.height - 40

        # draw Close control
        glColor3f(.2, .2, .2)
        glBegin(GL_POLYGON)
        glVertex3f(20, pos + 2, 0)
        glVertex3f(94, pos + 2, 0)
        glVertex3f(94, pos - 22, 0)
        glVertex3f(20, pos - 22, 0)
        glEnd()

        glColor3f(1, 1, 1)
        blf.position(0, 25, pos - 15, 0)
        blf.draw(0, "[X] Close")

        glColor3f(.2, .2, .2)
        glBegin(GL_POLYGON)
        glVertex3f(100, pos + 2, 0)
        glVertex3f(250, pos + 2, 0)
        glVertex3f(250, pos - 22, 0)
        glVertex3f(100, pos - 22, 0)
        glEnd()

        # draw Show/Hide control and actual reports if exists
        glColor3f(1, 1, 1)
        blf.position(0, 105, pos - 15, 0)
        if _Show3DViewReportOperator.is_shown():
            blf.draw(0, "[+] Show | [  ] Hide")

            blf.enable(0, blf.SHADOW)
            blf.size(0, 12, 72)
            glColor3f(1, 1, 1)
            pos -= 40
            for line in _Show3DViewReportOperator.get_lines():

                # finish printing if running out of space
                if pos - 60 < 0:
                    blf.position(0, 20, pos, 0)
                    blf.draw(0, "...")
                    break

                blf.position(0, 20, pos, 0)
                if "ERROR" in line:
                    blf.shadow(0, 5, 0.5, 0., 0, 1)
                elif "WARNING" in line:
                    blf.shadow(0, 5, 0.3, 0.15, 0, 1)

                blf.draw(0, line)
                pos -= 15
            blf.disable(0, blf.SHADOW)
        else:
            blf.draw(0, "[  ] Show | [+] Hide")
Пример #51
0
//! [get_region]

    @staticmethod
    def __render(self, context):
        # リージョン幅を取得するため、描画先のリージョンを得る
        region = RenderText.__get_region(context, 'VIEW_3D', 'WINDOW')

//! [call_render_region]
        # 描画先のリージョンへテキストを描画
        if region is not None:
            # 影の効果を設定
            blf.shadow(0, 3, 0.0, 1.0, 0.0, 0.5)
            # 影の位置を設定
            blf.shadow_offset(0, 2, -2)
            # 影の効果を有効化
            blf.enable(0, blf.SHADOW)
            RenderText.__render_text(
                40, 40, region.height - 120, "Hello Blender world!!"
            )
            # 影の効果を無効化
            blf.disable(0, blf.SHADOW)
            RenderText.__render_text(
                30, 40, region.height - 180, "Suzanne on your lap"
            )
//! [call_render_region]

    def invoke(self, context, event):
        sc = context.scene
        if context.area.type == 'VIEW_3D':
            # 開始ボタンが押された時の処理
            if sc.rt_running is False:
Пример #52
0
    def draw(self, parent, context):
        #get the addon settings/prefs
        settings = context.user_preferences.addons['piemenus'].preferences

        #grab the biggest text dimensions that we already calced previously        
        biggestdimensionX = self.biggest_dim_x
        biggestdimensionY = self.biggest_dim_y
        
        for it in self.sliders:
            #draw some text above it.
            blf.size(0, self.text_size, self.text_dpi)
            dimension = blf.dimensions(0, it.id)

            x = it.x - dimension[0]*.5
            y = it.y + (it.height + dimension[1])* 0.5 + 2
            # Draw text
            blf.enable(0, blf.SHADOW)
            blf.shadow_offset(0, 0, 0)
            blf.shadow(0, 5, 0.0, 0.0, 0.0, 1.0)
            bgl.glColor3f(self.rt, self.gt, self.bt)
            
            blf.position(0, x, y, 0)
            blf.draw(0, it.id)
            blf.disable(0, blf.SHADOW)
            
            

            #draw left side one color
            bgl.glColor4f(self.rsSelected,self.gsSelected, self.bsSelected,1.0)
            pmu.draw_outline_or_region(bgl.GL_TRIANGLE_FAN, it.screen_left)
            
            #draw the right side another color
            bgl.glColor4f(self.rsInner,self.gsInner, self.bsInner,1.0)
            pmu.draw_outline_or_region(bgl.GL_TRIANGLE_FAN, it.screen_right)
            
            #Draw box outline
            bgl.glColor4f(self.rsOutline,self.gsOutline, self.bsOutline,1.0)           
            pmu.draw_outline_or_region(bgl.GL_LINE_LOOP, it.screen_left)
            pmu.draw_outline_or_region(bgl.GL_LINE_LOOP, it.screen_right)
            
            #put the text on top
            blf.enable(0, blf.KERNING_DEFAULT)
            prop_text = str(getattr(it.data, it.prop, 0))[0:4]
            #prop_text = "Test"
            dimensions2 = blf.dimensions(0,prop_text)
            x2 =it.x - dimensions2[0] * 0.5
            y2 = it.y - dimensions2[1] * 0.5
            blf.position(0, x2, y2, 0)
            bgl.glColor4f(self.rt, self.gt, self.bt, 1.0)
            blf.draw(0, prop_text)
            blf.disable(0, blf.KERNING_DEFAULT)
                
        for it in self.menu_items:
            sel = it == parent.current
            it_poll = it.poll(context)
 
            # center item on the circle
            #x = (self.menu_x + it.x) - (dimension[0] * 0.5)
            #y = (self.menu_y + it.y) - (dimension[1] * 0.5)

            blf.size(0, self.text_size, self.text_dpi)
            dimension = blf.dimensions(0, it.id)

            #needed for box centering
            x = (it.x) - (biggestdimensionX * 0.5)
            y = (it.y) - (biggestdimensionY * 0.5)

            #needed offset for text centering
            blf.size(0, self.text_size, self.text_dpi)
            dimension = blf.dimensions(0, it.id)
            xt = ((biggestdimensionX-dimension[0]) * 0.5)
            yt = ((biggestdimensionY-dimension[1]) * 0.5)

            # Draw background buttons
            if sel and it_poll:
                bgl.glColor4f(self.ris, self.gis, self.bis, self.ais)
            else:
                bgl.glColor4f(self.ri, self.gi, self.bi, self.ai)
 
            #self.gl_pie_slice(bgl.GL_POLYGON, 8, it, x,y,30,90) #***
            #http://www.opengl.org/archives/resources/faq/technical/rasterization.htm#rast0120
            #self._round_box(bgl.GL_POLYGON, x - 20, y - 5, x + biggestdimensionX + 20, y + biggestdimensionY + 5)          
            
            if it.screen_poly_bound:
                shape = it.screen_poly_bound            
                pmu.draw_outline_or_region(bgl.GL_TRIANGLE_FAN, shape)
                bgl.glColor4f(self.ro, self.go, self.bo, 1.0)
                pmu.draw_outline_or_region(bgl.GL_LINE_LOOP, shape)
            
            bgl.glColor4f(self.ri, self.gi, self.bi, self.ai)
            #draw the circle
            if settings.clockBool:
                self._circle_(bgl.GL_TRIANGLE_FAN, (self.menu_x), (self.menu_y), 20)
            
                #draw the circle outline
                bgl.glColor4f(self.ro, self.go, self.bo, 1.0)
                self._circle_(bgl.GL_LINE_LOOP, (self.menu_x), (self.menu_y), 20)

                self._pointer_(bgl.GL_TRIANGLE_STRIP, (self.menu_x), (self.menu_y), self.pointerangle )
 
            # Draw text
            blf.enable(0, blf.SHADOW)
            blf.shadow_offset(0, 0, 0)
            blf.shadow(0, 5, 0.0, 0.0, 0.0, 1.0)
            if it_poll:
                bgl.glColor3f(self.rt, self.gt, self.bt)
            else:  # grayed out
                bgl.glColor3f(0.5, 0.5, 0.5)
            blf.position(0, x+xt, y+yt, 0)
            blf.draw(0, it.id)
            blf.disable(0, blf.SHADOW)
        
        
        #bind the named texure to GL_TEXTURE_2D
        #http://stackoverflow.com/questions/11217121/how-to-manage-memory-with-texture-in-opengl
        bgl.glBindTexture(bgl.GL_TEXTURE_2D, settings.pieIconBindcode)
        bgl.glTexParameteri(bgl.GL_TEXTURE_2D, bgl.GL_TEXTURE_MIN_FILTER, bgl.GL_NEAREST)
        
        bgl.glEnable(bgl.GL_TEXTURE_2D)
        bgl.glEnable(bgl.GL_BLEND) 
        
        for it in self.menu_items:
            bgl.glColor4f(1, 1, 1, 1)
            if it.icon:
                #place the icon quad
                verts = it.screen_icon_quad
            
                bgl.glBegin(bgl.GL_QUADS)
            
                bgl.glTexCoord2f(it.tex_coords[0][0],it.tex_coords[0][1])
                bgl.glVertex2f(verts[0][0],verts[0][1])
                bgl.glTexCoord2f(it.tex_coords[1][0],it.tex_coords[1][1])
                bgl.glVertex2f(verts[1][0],verts[1][1])
                bgl.glTexCoord2f(it.tex_coords[2][0],it.tex_coords[2][1])
                bgl.glVertex2f(verts[2][0],verts[2][1])
                bgl.glTexCoord2f(it.tex_coords[3][0],it.tex_coords[3][1])
                bgl.glVertex2f(verts[3][0],verts[3][1])
            
                bgl.glEnd()
            
            #TODO
            #text value in center?
            #labe over top?    
        bgl.glDisable(bgl.GL_BLEND)
        bgl.glDisable(bgl.GL_TEXTURE_2D)   
Пример #53
0
def display_instructions(region, rv3d, instruct, keys_aff, keys_nav, keys_neg):


    userpref = bpy.context.user_preferences
    system = userpref.system
    rwtools = 0
    rwui = 0

    np_print(system.window_draw_method, system.use_region_overlap)


    if system.use_region_overlap:
        if system.window_draw_method in ('TRIPLE_BUFFER', 'AUTOMATIC') :

            area = bpy.context.area
            np_print('GO', area.regions)
            for r in area.regions:
                if r.type == 'TOOLS':
                    rwtools = r.width
                elif r.type == 'UI':
                    rwui = r.width

    np_print('rwtools', rwtools, 'rwui', rwui)
    field_keys_y = 46
    field_keys_x = 80
    rw = region.width
    rh = region.height
    np_print('rw, rh', rw, rh)

    expand = False
    crop = False

    len_aff_max = rw - 140 - rwtools - rwui
    len_aff = len(keys_aff) * 5
    len_neg = len(keys_neg) * 5
    len_ins = len(instruct) * 18
    if len_aff > len_aff_max: expand = True

    rw_min = 480
    rh_min = 280
    if rw - rwtools - rwui < rw_min or rh < rh_min: crop = True


    version = '020'
    font_id = 0

    keys_aff_1 = copy.deepcopy(keys_aff)
    keys_aff_2 = ' '
    if expand:
        keys_aff_1 = ''
        keys_aff_2 = ''
        np_print('len(keys_aff)', len(keys_aff))
        stop = 0
        for i in range (0, len(keys_aff)-1):
            #np_print(keys_aff[i])
            if keys_aff[i] == ',' and i * 5 <= len_aff_max and i > stop:
                stop = i
        np_print('stop', stop)
        for i in range(0, stop + 1):
            keys_aff_1 = keys_aff_1 + keys_aff[i]
        for i in range(stop + 2, len(keys_aff)):
            keys_aff_2 = keys_aff_2 + keys_aff[i]
        np_print(keys_aff_1)
        np_print(keys_aff_2)


    field_keys_aff_1 = [[field_keys_x + rwtools, field_keys_y + 21], [field_keys_x + rwtools, field_keys_y + 39], [rw - int(field_keys_x / 2) - rwui, field_keys_y + 39], [rw - int(field_keys_x / 2) - rwui, field_keys_y + 21]]
    field_keys_aff_2 = copy.deepcopy(field_keys_aff_1)
    field_keys_neg = [[field_keys_x + rwtools, field_keys_y], [field_keys_x + rwtools, field_keys_y + 18], [rw - int(field_keys_x / 2) - rwui, field_keys_y + 18], [rw - int(field_keys_x / 2) - rwui, field_keys_y]]
    if expand:
        field_keys_aff_2 = copy.deepcopy(field_keys_neg)
        field_keys_neg = [[field_keys_x + rwtools, field_keys_y - 21], [field_keys_x + rwtools, field_keys_y - 3], [rw - int(field_keys_x / 2) - rwui, field_keys_y - 3], [rw - int(field_keys_x / 2) - rwui, field_keys_y - 21]]

    size_font_np = 25
    size_font_instruct = 21
    size_font_keys = 11
    len_np_ins = len_ins + int(size_font_np * 2.1)

    pos_font_np_x = (rw - len_np_ins / 2) / 2 + rwtools / 2 - rwui / 2
    pos_font_np_y = 150
    if crop: pos_font_np_y = 75
    pos_font_instruct_x = pos_font_np_x + int(size_font_np * 2.1)
    pos_font_instruct_y = pos_font_np_y + 4
    pos_font_keys_aff_1_x = field_keys_x + 8 + rwtools
    pos_font_keys_aff_1_y = field_keys_y + 26
    pos_font_keys_aff_2_x = copy.deepcopy(pos_font_keys_aff_1_x)
    pos_font_keys_aff_2_y = copy.deepcopy(pos_font_keys_aff_1_y)
    pos_font_keys_nav_x = field_keys_x + 8 + rwtools
    pos_font_keys_nav_y = field_keys_y + 5
    pos_font_keys_neg_x = rw - 52 - len_neg - rwui
    np_print('len_neg', len_neg)
    np_print('pos_font_keys_neg_x', pos_font_keys_neg_x)
    pos_font_keys_neg_y = field_keys_y + 5
    if expand:
        pos_font_keys_aff_2_x = field_keys_x + 8 + rwtools
        pos_font_keys_aff_2_y = field_keys_y + 5
        pos_font_keys_nav_x = field_keys_x + 8 + rwtools
        pos_font_keys_nav_y = field_keys_y - 16
        pos_font_keys_neg_x = rw - 52 - len_neg - rwui
        pos_font_keys_neg_y = field_keys_y - 16 - rwui

    col_font_np = addon_settings_graph()['col_font_np']
    col_font_instruct_main = addon_settings_graph()['col_font_instruct_main']
    col_font_instruct_shadow = addon_settings_graph()['col_font_instruct_shadow']
    col_font_keys = addon_settings_graph()['col_font_keys']
    col_field_keys_aff = addon_settings_graph()['col_field_keys_aff']
    col_field_keys_neg = addon_settings_graph()['col_field_keys_neg']



    # instructions - NP:

    bgl.glColor4f(*col_font_np)
    blf.size(font_id, size_font_np, 72)
    blf.position(font_id, pos_font_np_x, pos_font_np_y, 0)
    blf.draw(font_id, 'NP')

    blf.enable(font_id, ROTATION)
    ang = radians(90)
    blf.size(font_id, int(size_font_np / 2.2), 72)
    blf.rotation(font_id, ang)
    blf.position(font_id, pos_font_np_x + int(size_font_np * 1.72) , pos_font_np_y - 2, 0)
    blf.draw(font_id, version)
    blf.disable(font_id, ROTATION)

    # instructions - instruct:

    bgl.glColor4f(*col_font_instruct_shadow)
    blf.position(font_id, pos_font_instruct_x + 1, pos_font_instruct_y - 1, 0)
    blf.size(font_id, size_font_instruct, 72)
    blf.draw(font_id, instruct)

    bgl.glColor4f(*col_font_instruct_main)
    blf.position(font_id, pos_font_instruct_x, pos_font_instruct_y, 0)
    blf.size(font_id, size_font_instruct, 72)
    blf.draw(font_id, instruct)

    bgl.glDisable(bgl.GL_BLEND)

    # instructions - keys - backdrop fields:

    bgl.glEnable(bgl.GL_BLEND)

    if crop == False:

        bgl.glColor4f(*col_field_keys_aff)
        bgl.glBegin(bgl.GL_TRIANGLE_FAN)
        for co in field_keys_aff_1:
            bgl.glVertex2f(*co)
        bgl.glEnd()

        bgl.glColor4f(*col_field_keys_aff)
        bgl.glBegin(bgl.GL_TRIANGLE_FAN)
        for co in field_keys_aff_2:
            bgl.glVertex2f(*co)
        bgl.glEnd()

        bgl.glColor4f(*col_field_keys_neg)
        bgl.glBegin(bgl.GL_TRIANGLE_FAN)
        for co in field_keys_neg:
            bgl.glVertex2f(*co)
        bgl.glEnd()


        # instructions - keys - writing:

        bgl.glColor4f(*col_font_keys)
        blf.size(font_id, size_font_keys, 72)

        blf.position(font_id, pos_font_keys_aff_1_x, pos_font_keys_aff_1_y, 0)
        blf.draw(font_id, keys_aff_1)

        blf.position(font_id, pos_font_keys_aff_2_x, pos_font_keys_aff_2_y, 0)
        blf.draw(font_id, keys_aff_2)

        blf.position(font_id, pos_font_keys_nav_x, pos_font_keys_nav_y, 0)
        blf.draw(font_id, keys_nav)

        blf.position(font_id, pos_font_keys_neg_x, pos_font_keys_neg_y, 0)
        blf.draw(font_id, keys_neg)
Пример #54
0
 def enable_word_wrap(fontid=None):
     # note: not a listed option in docs for `blf.enable`, but see `blf.word_wrap`
     return blf.enable(FontManager.load(fontid), blf.WORD_WRAP)
def draw_callback_px_text(self, context):
    wm = context.window_manager
    sc = context.scene
    if not wm.screencast_keys_keys:
        return

    font_size  = sc.screencast_keys_font_size
    mouse_size = sc.screencast_keys_mouse_size
    box_draw   = sc.screencast_keys_box_draw
    pos_x, pos_y = getDisplayLocation(context)
    label_time_max = sc.screencast_keys_fade_time

    # draw text in the 3D View
    blf.size(0, sc.screencast_keys_font_size, 72)
    blf.enable(0, blf.SHADOW)
    blf.shadow_offset(0, 1, -1)
    blf.shadow(0, 5, 0.0, 0.0, 0.0, 0.8)

    font_color_r, font_color_g, font_color_b, font_color_alpha = sc.screencast_keys_text_color
    final = 0
    row_count = len(self.key)

    keypos_x = pos_x

    if sc.screencast_keys_mouse_position == 'left':
        keypos_x += mouse_size * MOUSE_RATIO * 1.7
    if sc.screencast_keys_mouse != 'icon':
        keypos_x -= mouse_size * MOUSE_RATIO
    if sc.screencast_keys_mouse_position == 'right' and sc.screencast_keys_mouse != 'icon':
        keypos_x = pos_x

    shift = 0

    # we want to make sure we can shift vertically the text if the mouse is big,
    # but don't care if aligned to right 
    if mouse_size > font_size*row_count and not sc.screencast_keys_mouse_position == 'right':
        shift = (mouse_size - font_size*row_count) / 2

    text_width, text_height = 0,0
    row_count = 0
    alpha = 1.0

    for i in range(len(self.key)):
        label_time = time.time() - self.time[i]
        if label_time < label_time_max: # only display key-presses of last 2 seconds
            if label_time > (label_time_max / 1.2):
                blf.blur(0, 1)
            if label_time > (label_time_max / 1.1):
                blf.blur(0, 3)
            keypos_y = pos_y + shift + font_size*(i+0.1)

            blf.position(0, keypos_x, keypos_y , 0)
            alpha = min(1.0, max(0.0, label_time_max * (label_time_max - label_time)))
            bgl.glColor4f(font_color_r, font_color_g, font_color_b, font_color_alpha * alpha)
            blf.draw(0, self.key[i])
            text_width, text_height = getBoundingBox(text_width, text_height,
                self.key[i])
            row_count += 1
            final = i + 1
        else:
            break

    # remove blurriness 

    # disable shadows so they don't appear all over blender
    blf.blur(0,0)
    blf.disable(0, blf.SHADOW)

    # get rid of status texts that aren't displayed anymore
    self.key = self.key[:final]
    self.time = self.time[:final]

    # draw graphical representation of the mouse
    if sc.screencast_keys_mouse == 'icon':
        for shape in ["mouse", "left_button", "middle_button", "right_button"]:
            draw_mouse(context, shape, "outline", font_color_alpha * 0.4)
        final = 0

        for i in range(len(self.mouse)):
            click_time = time.time() - self.mouse_time[i]
            if click_time < 2:
                shape = map_mouse_event(self.mouse[i])
                if shape:
                    alpha = min(1.0, max(0.0, 2 * (2 - click_time)))
                    draw_mouse(context, shape, "filled", alpha)
                final = i + 1
            else:
                break

    # get rid of mouse clicks that aren't displayed anymore
    self.mouse = self.mouse[:final]
    self.mouse_time = self.mouse_time[:final]
Пример #56
0
def draw_callback_px(self, context):
    # circle graphic, text, and slider
    unify_settings = bpy.context.tool_settings.unified_paint_settings
    strength = unify_settings.strength if self.uni_str else self.brush.strength
    size = unify_settings.size if self.uni_size else self.brush.size
    
    if self.graphic:
        bgl.glEnable(bgl.GL_BLEND)
        bgl.glColor4f(self.brushcolor.r, self.brushcolor.g, self.brushcolor.b, strength * 0.25)
        bgl.glBegin(bgl.GL_POLYGON)
        for x, y in self.circlepoints:
            bgl.glVertex2i(int(size * x) + self.cur[0], int(size * y) + self.cur[1])
        bgl.glEnd()
        bgl.glDisable(bgl.GL_BLEND)
        bgl.glColor4f(0.0, 0.0, 0.0, 1.0)
    
    if self.text != 'NONE' and self.doingstr:
        if self.text == 'MEDIUM':
            fontsize = 11
        elif self.text == 'LARGE':
            fontsize = 22
        else:
            fontsize = 8
        
        font_id = 0
        blf.size(font_id, fontsize, 72)
        blf.shadow(font_id, 0, 0.0, 0.0, 0.0, 1.0)
        blf.enable(font_id, blf.SHADOW)
        
        if strength < 0.001:
            text = "0.001"
        else:
            text = str(strength)[0:5]
        textsize = blf.dimensions(font_id, text)
        
        xpos = self.start[0] + self.offset[0]
        ypos = self.start[1] + self.offset[1]
        
        bgl.glEnable(bgl.GL_BLEND)
        bgl.glColor4f(self.backcolor.r, self.backcolor.g, self.backcolor.b, 0.5)
        
        bgl.glBegin(bgl.GL_POLYGON)
        for x, y in self.rectpoints:
            bgl.glVertex2i(int(textsize[0] * x) + xpos, int(textsize[1] * y) + ypos)
        bgl.glEnd()
        
        bgl.glDisable(bgl.GL_BLEND)
        bgl.glColor4f(0.0, 0.0, 0.0, 1.0)
        
        blf.position(font_id, xpos, ypos, 0)
        blf.draw(font_id, text)
        
        blf.disable(font_id, blf.SHADOW)
    
    if self.slider != 'NONE' and self.doingstr:
        bgl.glEnable(bgl.GL_BLEND)
        bgl.glColor4f(self.backcolor.r, self.backcolor.g, self.backcolor.b, 0.5)
        
        xpos = self.start[0] + self.offset[0] - self.sliderwidth + (32 if self.text == 'MEDIUM' else 64 if self.text == 'LARGE' else 23)
        ypos = self.start[1] + self.offset[1] - self.sliderheight# + (1 if self.slider != 'SMALL' else 0)
        
        if strength <= 1.0:
            sliderscale = strength
        elif strength > 5.0:
            sliderscale = strength / 10
        elif strength > 2.0:
            sliderscale = strength / 5
        else:
            sliderscale = strength / 2
        
        bgl.glBegin(bgl.GL_POLYGON)
        for x, y in self.rectpoints:
            bgl.glVertex2i(int(self.sliderwidth * x) + xpos, int(self.sliderheight * y) + ypos - 1)
        bgl.glEnd()
        
        bgl.glColor4f(self.frontcolor.r, self.frontcolor.g, self.frontcolor.b, 0.8)
        
        bgl.glBegin(bgl.GL_POLYGON)
        for x, y in self.rectpoints:
            bgl.glVertex2i(int(self.sliderwidth * x * sliderscale) + xpos, int(self.sliderheight * y * 0.75) + ypos)
        bgl.glEnd()
        
        bgl.glDisable(bgl.GL_BLEND)
        bgl.glColor4f(0.0, 0.0, 0.0, 1.0)
Пример #57
0
	def draw(self):
		if self.visible == False: return
		module.post_draw_step += 1
		
		cam = self.scene.active_camera
		orth = cam.ortho_scale
		
		height = render.getWindowHeight()
		width = render.getWindowWidth()
		near = cam.near
		far = cam.far
		h = cam.worldPosition.z
		font_id = Label._fontname_id[self._font]
		unit = width/orth
		self._glunit = unit
		rpos = self._position - cam.worldPosition
		
		bgl.glMatrixMode(bgl.GL_PROJECTION)
		bgl.glLoadIdentity()
		bgl.gluOrtho2D(0, width, 0, height)
		bgl.glMatrixMode(bgl.GL_MODELVIEW)
		bgl.glLoadIdentity()
		
		bgl.glEnable(bgl.GL_BLEND)
		bgl.glBlendFunc(bgl.GL_SRC_ALPHA, bgl.GL_ONE_MINUS_SRC_ALPHA)
		bgl.glAlphaFunc(bgl.GL_SRC_ALPHA, 1)
		
		#Z AXIS
		oh = (far-near)/2
		ortho_unit = 1/oh
		dh = oh

		pos = list([width/2+rpos[0]*unit, height/2+rpos[1]*unit, dh*ortho_unit + rpos[2]*ortho_unit])
		if self._lastscale != self.scale or True:
			blf.size(font_id, int(self.scale.x*unit), 72)
		else:
			if self._lastorth != orth:
				sc = (float(self._lastorth) / float(orth)) * self.scale.x
				bgl.glScalef(sc,sc,1)
				print(str(self._lastorth) + " " + str(orth))
				pos[0] /= sc
				pos[1] /= sc
				
			else:
				self._lastorth = orth
		
		x, y = blf.dimensions(font_id, self._text) #NOTE: Always after blf.size()
		
		if self.align == ALIGN_CENTER:
			pos[0] -= (x)/2 * math.cos(self._rotation.z)
			pos[1] -= x/2 * math.sin(self._rotation.z)
		if self.align == ALIGN_RIGHT:
			pos[0] -= x * math.cos(self._rotation.z)
			pos[1] -= x * math.sin(self._rotation.z)
			
		if self.middle_height == True:
			pos[0] -= y/4 * math.sin(self._rotation.z)
			pos[1] -= y/4 * math.cos(self._rotation.z)
		
		blf.position(font_id, pos[0], pos[1], pos[2])
		blf.enable(font_id, blf.ROTATION)
		if self.rotation.z > 0.01 or self.rotation.z < -0.01:
			blf.rotation(font_id, self._rotation.z)
		else:
			blf.rotation(font_id, 0)
		
		if self.shadow == True:
			blf.position(font_id, pos[0]+self.shadow_offset[0], pos[1]+self.shadow_offset[1], pos[2])
			bgl.glColor4f(*self.shadow_color)
			blf.blur(font_id, self.shadow_blur)
			blf.draw(font_id, self._text)
			blf.position(font_id, pos[0], pos[1], pos[2])
			
		bgl.glColor4f(*self._color)
		blf.blur(font_id, self.blur)
		blf.draw(font_id, self._text)
		
		blf.disable(font_id, blf.ROTATION)
		
		self._lastscale = self.scale