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


Python blf.dimensions方法代码示例

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


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

示例1: _draw_callback_px

# 需要导入模块: import blf [as 别名]
# 或者: from blf import dimensions [as 别名]
def _draw_callback_px(self, context):

    try:
        print("SELF", self)
    except:
        print("red err?")

    r_width = context.region.width
    r_height = context.region.height
    font_id = 0  # TODO: need to find out how best to get font_id

    blf.size(font_id, 11, 72)
    text_size = blf.dimensions(0, self.view_name)

    text_x = r_width - text_size[0] - 10
    text_y = r_height - text_size[1] - 8
    blf.position(font_id, text_x, text_y, 0)
    blf.draw(font_id, self.view_name) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:20,代码来源:ui.py

示例2: DrawCenterText

# 需要导入模块: import blf [as 别名]
# 或者: from blf import dimensions [as 别名]
def DrawCenterText(text, xt, yt, Size, Color, self):
    font_id = 0
    # Decalage Ombre
    Sshadow_x = 2
    Sshadow_y = -2

    blf.size(font_id, Size, 72)
    blf.position(font_id, xt + Sshadow_x - blf.dimensions(font_id, text)[0] / 2, yt + Sshadow_y, 0)
    bgl.glColor4f(0.0, 0.0, 0.0, 1.0)

    blf.draw(font_id, text)
    blf.position(font_id, xt - blf.dimensions(font_id, text)[0] / 2, yt, 0)
    if Color is not None:
        mColor = mathutils.Color((Color[0], Color[1], Color[2]))
        bgl.glColor4f(mColor.r, mColor.g, mColor.b, 1.0)
    else:
        bgl.glColor4f(1.0, 1.0, 1.0, 1.0)
    blf.draw(font_id, text)


# Draw text (Left position) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:23,代码来源:mesh_carver.py

示例3: onscreen_warning

# 需要导入模块: import blf [as 别名]
# 或者: from blf import dimensions [as 别名]
def onscreen_warning(self, x, y):
        gamma = self.gamma_correction

        fontid = 1
        blf.size(fontid, self.prefs.view_font_size_report, 72)
        blf.color(fontid, *gamma((1.0, 0.3, 0.3, 1.0)))

        _, font_h = blf.dimensions(fontid, "Row Height")
        font_row_height = font_h * 2
        y += font_h

        for row in self.warn:
            y -= font_row_height

            blf.position(fontid, x, y, 0.0)
            blf.draw(fontid, row)

        return y 
开发者ID:mrachinskiy,项目名称:jewelcraft,代码行数:20,代码来源:onscreen_text.py

示例4: draw_callback_px

# 需要导入模块: import blf [as 别名]
# 或者: from blf import dimensions [as 别名]
def draw_callback_px(self, context):

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

    # draw some text
    y = context.region.height
    dims = blf.dimensions(0, 'A')

    blf.position(font_id, 10, y - 20 - dims[1], 0)
    blf.size(font_id, 20, 72)

    if context.area.x == self.area_align.x:
        blf.draw(font_id, "Align: "+ self.align_msg)
        points = [self.obj_align.matrix_world * p for p in self.align_points]
        color = (1,0,0,1)
    else:
        blf.draw(font_id, "Base: " + self.base_msg)
        points = [self.obj_align.matrix_world * p for p in self.base_points]
        color = (0,1,0,1)

    draw_3d_points_revised(context, points, color, 4)

    for i, vec in enumerate(points):
        ind = str(i)
        draw_3d_text(context, font_id, ind, vec) 
开发者ID:patmo141,项目名称:object_alignment,代码行数:27,代码来源:align_pick_points.py

示例5: draw_callback_2d

# 需要导入模块: import blf [as 别名]
# 或者: from blf import dimensions [as 别名]
def draw_callback_2d(self, op, context):

        # Draw text for add object mode
        header = "- Add Object Mode (Type: " + context.scene.add_object_type + ") -"
        text = "Ctrl + Left Click = Add | Esc = Exit"

        blf.color(1, 1, 1, 1, 1)
        blf.size(0, 20, 72)
        blf.size(1, 16, 72)

        region = context.region
        xt = int(region.width / 2.0)

        blf.position(0, xt - blf.dimensions(0, header)[0] / 2, 50 , 0)
        blf.draw(0, header)

        blf.position(1, xt - blf.dimensions(1, text)[0] / 2, 20 , 0)
        blf.draw(1, text) 
开发者ID:jayanam,项目名称:fast-sculpt,代码行数:20,代码来源:fsc_add_object_op.py

示例6: draw_text

# 需要导入模块: import blf [as 别名]
# 或者: from blf import dimensions [as 别名]
def draw_text(x, y, size, text, justify="left", color=(1.0, 1.0, 1.0, 1.0)):
    font_id = 0
    blf.color(font_id, *color)
    if justify == "right":
        text_width, text_height = blf.dimensions(font_id, text)
    else:
        text_width = 0
    blf.position(font_id, x - text_width, y, 0)
    blf.size(font_id, size, 72)
    blf.draw(font_id, text) 
开发者ID:GDQuest,项目名称:blender-power-sequencer,代码行数:12,代码来源:draw.py

示例7: draw_gedge_text

# 需要导入模块: import blf [as 别名]
# 或者: from blf import dimensions [as 别名]
def draw_gedge_text(gedge,context, text):
    l = len(gedge.cache_igverts)
    if l > 4:
        n_quads = math.floor(l/2) + 1
        mid_vert_ind = math.floor(l/2)
        mid_vert = gedge.cache_igverts[mid_vert_ind]
        position_3d = mid_vert.position + 1.5 * mid_vert.tangent_y * mid_vert.radius
    else:
        position_3d = (gedge.gvert0.position + gedge.gvert3.position)/2
    
    position_2d = location_3d_to_region_2d(context.region, context.space_data.region_3d,position_3d)
    txt_width, txt_height = blf.dimensions(0, text)
    blf.position(0, position_2d[0]-(txt_width/2), position_2d[1]-(txt_height/2), 0)
    blf.draw(0, text) 
开发者ID:CGCookie,项目名称:retopology-polystrips,代码行数:16,代码来源:polystrips_draw.py

示例8: draw_text_background

# 需要导入模块: import blf [as 别名]
# 或者: from blf import dimensions [as 别名]
def draw_text_background(text, font_id, x, y, background_color):
    width = blf.dimensions(font_id, text)[0]
    height = blf.dimensions(font_id, string.printable)[1]
    margin = height * 0.2

    draw_rect(x, y - margin, x + width, y + height - margin, background_color) 
开发者ID:nutti,项目名称:Screencast-Keys,代码行数:8,代码来源:ops.py

示例9: get_text_offset_for_alignment

# 需要导入模块: import blf [as 别名]
# 或者: from blf import dimensions [as 别名]
def get_text_offset_for_alignment(cls, font_id, text, context):
        tw = blf.dimensions(font_id, text)[0]

        return cls.get_offset_for_alignment(tw, context) 
开发者ID:nutti,项目名称:Screencast-Keys,代码行数:6,代码来源:ops.py

示例10: draw_callback_px

# 需要导入模块: import blf [as 别名]
# 或者: from blf import dimensions [as 别名]
def draw_callback_px(self, context):
    font_id = 0  # XXX, need to find out how best to get this.

    offset = 10
    text_height = 10
    text_length = int(len(self.mouse_text) * 7.3)
    
    if self.header_text != "":
        blf.size(font_id, 17, 72)
        text_w, text_h = blf.dimensions(font_id,self.header_text)
        blf.position(font_id, context.area.width/2 - text_w/2, context.area.height - 50, 0)
        blf.draw(font_id, self.header_text)

    # 50% alpha, 2 pixel width line
    if self.mouse_text != "":
        bgl.glEnable(bgl.GL_BLEND)
        bgl.glColor4f(0.0, 0.0, 0.0, 0.5)
        bgl.glLineWidth(10)
    
        bgl.glBegin(bgl.GL_LINE_STRIP)
        bgl.glVertex2i(self.mouse_loc[0]-offset-5, self.mouse_loc[1]+offset)
        bgl.glVertex2i(self.mouse_loc[0]+text_length-offset, self.mouse_loc[1]+offset)
        bgl.glVertex2i(self.mouse_loc[0]+text_length-offset, self.mouse_loc[1]+offset+text_height)
        bgl.glVertex2i(self.mouse_loc[0]-offset-5, self.mouse_loc[1]+offset+text_height)
        bgl.glEnd()
        
        bgl.glColor4f(1.0, 1.0, 1.0, 1.0)
        blf.position(font_id, self.mouse_loc[0]-offset, self.mouse_loc[1]+offset, 0)
        blf.size(font_id, 15, 72)
        blf.draw(font_id, self.mouse_text)
        
    # restore opengl defaults
    bgl.glLineWidth(1)
    bgl.glDisable(bgl.GL_BLEND)
    bgl.glColor4f(0.0, 0.0, 0.0, 1.0) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:37,代码来源:utils.py

示例11: draw_exp_strings

# 需要导入模块: import blf [as 别名]
# 或者: from blf import dimensions [as 别名]
def draw_exp_strings(self, font_id, ofsx, ofsy, minwidth=40, \
						 pertition=',  ', start='', end='',
						 col=None, errcol=None):
		if start:
			if col:
				bgl.glColor4f(*col)
			blf.position(font_id, ofsx, ofsy, 0)
			blf.draw(font_id, start)
			text_width, text_height = blf.dimensions(font_id, start)
			ofsx += text_width
		for i, string in enumerate(self.exp_strings):
			value = self.get_exp_value(i)
			if col and value is not None:
				bgl.glColor4f(*col)
			elif errcol and value is None:
				bgl.glColor4f(*errcol)
			name = self.exp_names[i]
			text = name.format(exp=string)
			if len(self.exp_strings) > 1 and 0 < i < len(exp_strings) - 1:
				text = text + pertition
			blf.position(font_id, ofsx, ofsy, 0)
			blf.draw(font_id, text)
			text_width, text_height = blf.dimensions(font_id, text)
			text_width = max(minwidth, text_width)
			# caret
			if i == self.caret[0]:
				if col:
					bgl.glColor4f(*col)
				t = name.split('{')[0] + string[:self.caret[1]]
				t_width, t_height = blf.dimensions(font_id, t)
				x = ofsx + t_width
				glRectf(x, ofsy - 4, x + 1, ofsy + 14)
			ofsx += text_width
			if end and i == len(self.exp_strings) - 1:
				if col:
					bgl.glColor4f(*col)
				blf.position(font_id, ofsx, ofsy, 0)
				blf.draw(font_id, end) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:40,代码来源:view.py

示例12: blf_text_height_max

# 需要导入模块: import blf [as 别名]
# 或者: from blf import dimensions [as 别名]
def blf_text_height_max(fontid):
		text_width, text_height = blf.dimensions(fontid,
							  reduce(lambda x, y: x+chr(y), range(32, 127), ''))
		return text_height 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:6,代码来源:__init__.py

示例13: draw_unit

# 需要导入模块: import blf [as 别名]
# 或者: from blf import dimensions [as 别名]
def draw_unit(data, config):
	font = config.font_main
	sx = data.sx - 1
	text = number_adjust_column(10.0 ** data.unit_pow, data.unit_pow)

	blf.size(font.id, font.size, font.dpi)
	text_width, text_height = blf.dimensions(font.id, text)
	px = sx - text_width - font.offset * 2
	glColor4f(*config.color_background)
	glRectf(px, 0, sx, text_height + font.offset * 2)
	glColor4f(*config.color_main)
	draw_box(px, 0, text_width + font.offset * 2, text_height + font.offset * 2)
	blf.position(font.id, px + font.offset, font.offset, 0)
	blf.draw(font.id, text) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:16,代码来源:__init__.py

示例14: text_draw_position_along_line

# 需要导入模块: import blf [as 别名]
# 或者: from blf import dimensions [as 别名]
def text_draw_position_along_line(text, font, origin_vec, offset_vec, \
								  text_offset=None):
	# in 2D, retrun 3D
	text_width, text_height = blf.dimensions(font.id, text)
	if text_offset is None:
		text_offset = font.offset
	l = offset_vec.length
	offset_vec_normalized = offset_vec.normalized()
	v = (offset_vec_normalized[0] * (text_width / 2 + text_offset),
		  (offset_vec_normalized[1] * text_height / 2 + text_offset))
	vec = Vector([origin_vec[0] + offset_vec[0] + v[0] - text_width / 2, \
				  origin_vec[1] + offset_vec[1] + v[1] - text_height / 2, 0])
	return vec 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:15,代码来源:__init__.py

示例15: set_text

# 需要导入模块: import blf [as 别名]
# 或者: from blf import dimensions [as 别名]
def set_text(self, text):
        self.text = str(text)
        dims = blf.dimensions(self.font_id, self.text)
        self.w = dims[0]
        dims = blf.dimensions(self.font_id, "dp") # fontheight
        self.h = dims[1] 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:8,代码来源:space_view3d_enhanced_3d_cursor.py


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