本文整理汇总了Python中blf.position方法的典型用法代码示例。如果您正苦于以下问题:Python blf.position方法的具体用法?Python blf.position怎么用?Python blf.position使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类blf
的用法示例。
在下文中一共展示了blf.position方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw_callback_text
# 需要导入模块: import blf [as 别名]
# 或者: from blf import position [as 别名]
def draw_callback_text(self):
obj = bpy.context.active_object
### draw text for edge length detection
if self.shift and self.point_type == "EDGE":
p1 = obj.matrix_world * self.verts_edges_data[0]
p2 = obj.matrix_world * self.verts_edges_data[1]
length = (p1-p2).magnitude
font_id = 0
line = str(round(length,2))
bgl.glEnable(bgl.GL_BLEND)
bgl.glColor4f(1,1,1,1)
blf.position(font_id, self.mouse_2d_x-15, self.mouse_2d_y+30, 0)
blf.size(font_id, 20, 72)
blf.draw(font_id, line)
if self.mode == "EDIT_MESH":
draw_edit_mode(self,bpy.context,color=[1.0, 0.39, 0.41, 1.0],text="Edit Mesh Mode",offset=-20)
elif self.mode == "DRAW_BONE_SHAPE":
draw_edit_mode(self,bpy.context,color=[1.0, 0.39, 0.41, 1.0],text="Draw Bone Shape",offset=-20)
示例2: scale_tool_gvert
# 需要导入模块: import blf [as 别名]
# 或者: from blf import position [as 别名]
def scale_tool_gvert(self, command, eventd):
if command == 'init':
self.footer = 'Scaling GVerts'
sgv = self.sel_gvert
lgv = [ge.gvert1 if ge.gvert0==sgv else ge.gvert2 for ge in sgv.get_gedges() if ge]
self.tool_data = [(gv,Vector(gv.position)) for gv in lgv]
elif command == 'commit':
pass
elif command == 'undo':
for gv,p in self.tool_data:
gv.position = p
gv.update()
self.sel_gvert.update()
self.sel_gvert.update_visibility(eventd['r3d'], update_gedges=True)
else:
m = command
sgv = self.sel_gvert
p = sgv.position
for ge in sgv.get_gedges():
if not ge: continue
gv = ge.gvert1 if ge.gvert0 == self.sel_gvert else ge.gvert2
gv.position = p + (gv.position-p) * m
gv.update()
sgv.update()
self.sel_gvert.update_visibility(eventd['r3d'], update_gedges=True)
示例3: rotate_tool_gvert_neighbors
# 需要导入模块: import blf [as 别名]
# 或者: from blf import position [as 别名]
def rotate_tool_gvert_neighbors(self, command, eventd):
if command == 'init':
self.footer = 'Rotating GVerts'
self.tool_data = [(gv,Vector(gv.position)) for gv in self.sel_gvert.get_inner_gverts()]
elif command == 'commit':
pass
elif command == 'undo':
for gv,p in self.tool_data:
gv.position = p
gv.update()
else:
ang = command
q = Quaternion(self.sel_gvert.snap_norm, ang)
p = self.sel_gvert.position
for gv,up in self.tool_data:
gv.position = p+q*(up-p)
gv.update()
示例4: draw_callback_px
# 需要导入模块: import blf [as 别名]
# 或者: from blf import position [as 别名]
def draw_callback_px(self, context):
print("mouse points", len(self.mouse_path))
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, 20, 72)
blf.draw(font_id, "Hello Word " + str(len(self.mouse_path)))
# 50% alpha, 2 pixel width line
bgl.glEnable(bgl.GL_BLEND)
bgl.glColor4f(0.0, 0.0, 0.0, 0.5)
bgl.glLineWidth(2)
bgl.glBegin(bgl.GL_LINE_STRIP)
for x, y in self.mouse_path:
bgl.glVertex2i(x, y)
bgl.glEnd()
# restore opengl defaults
bgl.glLineWidth(1)
bgl.glDisable(bgl.GL_BLEND)
bgl.glColor4f(0.0, 0.0, 0.0, 1.0)
示例5: get_location
# 需要导入模块: import blf [as 别名]
# 或者: from blf import position [as 别名]
def get_location(frame, display_ob, offset_ob, curves):
if offset_ob:
bpy.context.scene.frame_set(frame)
display_mat = getattr(display_ob, "matrix", False)
if not display_mat:
# posebones have "matrix", objects have "matrix_world"
display_mat = display_ob.matrix_world
if offset_ob:
loc = display_mat.to_translation() + \
offset_ob.matrix_world.to_translation()
else:
loc = display_mat.to_translation()
else:
fcx, fcy, fcz = curves
locx = fcx.evaluate(frame)
locy = fcy.evaluate(frame)
locz = fcz.evaluate(frame)
loc = mathutils.Vector([locx, locy, locz])
return(loc)
# get position of keyframes and handles at the start of dragging
示例6: _draw_callback_px
# 需要导入模块: import blf [as 别名]
# 或者: from blf import position [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)
示例7: DrawCenterText
# 需要导入模块: import blf [as 别名]
# 或者: from blf import position [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)
示例8: DrawRightText
# 需要导入模块: import blf [as 别名]
# 或者: from blf import position [as 别名]
def DrawRightText(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], 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], 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)
# Opengl draws
示例9: onscreen_warning
# 需要导入模块: import blf [as 别名]
# 或者: from blf import position [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
示例10: draw
# 需要导入模块: import blf [as 别名]
# 或者: from blf import position [as 别名]
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.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, p.x, p.y, 0)
blf.draw(font_id, self.text)
if self.angle != 0:
blf.disable(font_id, blf.ROTATION)
示例11: instructions
# 需要导入模块: import blf [as 别名]
# 或者: from blf import position [as 别名]
def instructions(self, context, title, explanation, shortcuts):
"""
position from bottom to top
"""
prefs = self.get_prefs(context)
self.explanation.label = explanation
self.title.label = title
self.shortcuts = []
for key, label in shortcuts:
key = GlText(d=2, label=key,
font_size=prefs.feedback_size_shortcut,
colour=prefs.feedback_colour_key)
label = GlText(d=2, label=' : ' + label,
font_size=prefs.feedback_size_shortcut,
colour=prefs.feedback_colour_shortcut)
ks = key.text_size(context)
ls = label.text_size(context)
self.shortcuts.append([key, ks, label, ls])
示例12: draw_callback_px
# 需要导入模块: import blf [as 别名]
# 或者: from blf import position [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)
示例13: draw_3d_text
# 需要导入模块: import blf [as 别名]
# 或者: from blf import position [as 别名]
def draw_3d_text(context, font_id, text, vec):
region = context.region
region3d = context.space_data.region_3d
region_mid_width = region.width / 2.0
region_mid_height = region.height / 2.0
perspective_matrix = region3d.perspective_matrix.copy()
vec_4d = perspective_matrix * vec.to_4d()
if vec_4d.w > 0.0:
x = region_mid_width + region_mid_width * (vec_4d.x / vec_4d.w)
y = region_mid_height + region_mid_height * (vec_4d.y / vec_4d.w)
blf.position(font_id, x + 3.0, y - 4.0, 0.0)
blf.draw(font_id, text)
################################################
############# RAYCASTING AND SNAPPING ##########
################################################
# Jon Denning for Retopoflow
示例14: draw_callback_2d
# 需要导入模块: import blf [as 别名]
# 或者: from blf import position [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)
示例15: draw_text
# 需要导入模块: import blf [as 别名]
# 或者: from blf import position [as 别名]
def draw_text(text, position, color=(1.0, 1.0, 1.0, 1.0), size=14, dpi=150, font_id=0):
"""
Args:
text:
position:
color: (Default value = (1.0)
1.0:
1.0):
size: (Default value = 14)
dpi: (Default value = 150)
font_id: (Default value = 0)
Returns:
"""
bgl.glColor4f(*color)
blf.position(font_id, *position, 0.25)
blf.size(font_id, size, dpi)
blf.draw(font_id, text)