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


Python Path.add方法代码示例

本文整理汇总了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
开发者ID:alessandrostone,项目名称:nodebox,代码行数:60,代码来源:pyvector.py

示例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
开发者ID:cleliodpaula,项目名称:nodebox,代码行数:13,代码来源:corevector.py

示例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
开发者ID:alessandrostone,项目名称:nodebox,代码行数:17,代码来源:pyvector.py


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