本文整理汇总了Python中nodebox.graphics.Path.add方法的典型用法代码示例。如果您正苦于以下问题:Python Path.add方法的具体用法?Python Path.add怎么用?Python Path.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nodebox.graphics.Path
的用法示例。
在下文中一共展示了Path.add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: text_on_path
# 需要导入模块: from nodebox.graphics import Path [as 别名]
# 或者: from nodebox.graphics.Path import add [as 别名]
def text_on_path(text, shape, font_name, font_size, alignment, margin, baseline_offset):
if shape is None or shape.length <= 0: return None
if text is None: return None
text = unicode(text)
if isinstance(shape, Path):
shape = shape.asGeometry()
p = Path()
fm = get_font_metrics(font_name, font_size)
string_width = textwidth(text, fm)
dw = string_width / shape.length
if alignment == "trailing":
first = True
for char in text:
char_width = textwidth(char, fm)
if first:
t = (99.9 - margin) / 100.0
first = False
else:
t -= char_width / string_width * dw
t = t % 1.0
margin = t * 100
first = True
for char in text:
char_width = textwidth(char, fm)
if first:
t = margin / 100.0
first = False
else:
t += char_width / string_width * dw
# Always loop (the other behavior is weird)
t = t % 1.0
pt1 = shape.pointAt(t)
pt2 = shape.pointAt(t + 0.0000001)
a = angle(pt2.x, pt2.y, pt1.x, pt1.y)
tp = Text(char, -char_width, -baseline_offset)
tp.align = Text.Align.LEFT
tp.fontName = font_name
tp.fontSize = font_size
tp.translate(pt1.x, pt1.y)
tp.rotate(a - 180)
for contour in tp.path.contours:
p.add(contour)
return p
示例2: delete_points
# 需要导入模块: from nodebox.graphics import Path [as 别名]
# 或者: from nodebox.graphics.Path import add [as 别名]
def delete_points(path, bounding, delete_selected=True):
if path is None or bounding is None: return None
new_path = Path(path, False) # cloneContours = False
for old_contour in path.contours:
new_contour = Contour()
for point in old_contour.points:
if bounding.contains(point) == delete_selected:
new_contour.addPoint(Point(point.x, point.y, point.type))
new_contour.closed = old_contour.closed
new_path.add(new_contour)
return new_path
示例3: _function
# 需要导入模块: from nodebox.graphics import Path [as 别名]
# 或者: from nodebox.graphics.Path import add [as 别名]
def _function(shape, *args, **kwargs):
from java.util import List
if isinstance(shape, (list, tuple, List)):
return fn(shape, *args, **kwargs)
elif isinstance(shape, Path):
new_path = Path(shape, False)
for c in shape.contours:
new_path.add(Contour(fn(c.points, *args, **kwargs), c.closed))
return new_path
elif isinstance(shape, Geometry):
new_geo = Geometry()
for path in shape.paths:
new_geo.add(_map_geo_to_points(fn)(path, *args, **kwargs))
return new_geo
return None