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


Python Transform._set_matrix方法代码示例

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


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

示例1: parse_transform

# 需要导入模块: from nodebox.graphics import Transform [as 别名]
# 或者: from nodebox.graphics.Transform import _set_matrix [as 别名]
def parse_transform(e, path):
    
    """ Transform the path according to a defined matrix.
    
    Attempts to extract a transform="matrix()|translate()" attribute.
    Transforms the path accordingly.
    
    """
    
    t = get_attribute(e, "transform", default="")
    
    for mode in ("matrix", "translate"):
        if t.startswith(mode):
            v = t.replace(mode, "").lstrip("(").rstrip(")")
            v = v.replace(", ", ",").replace(" ", ",")
            v = [float(x) for x in v.split(",")]
            from nodebox.graphics import Transform
            t = Transform()            
            if mode == "matrix":
                t._set_matrix(v)
            elif mode == "translate":
                t.translate(*v)
            path = t.transformBezierPath(path)
            break

    # Transformations can also be defined as <g transform="matrix()"><path /><g>
    # instead of <g><path transform="matrix() /></g>.
    e = e.parentNode
    if e and e.tagName == "g":
        path = parse_transform(e, path)
        
    return path
开发者ID:msarch,项目名称:py,代码行数:34,代码来源:__init__.py

示例2: add_transform_matrix

# 需要导入模块: from nodebox.graphics import Transform [as 别名]
# 或者: from nodebox.graphics.Transform import _set_matrix [as 别名]
def add_transform_matrix(e, path):
    
    """ Transform the path according to a defined matrix.
    
    Attempts to extract a transform="matrix()" attribute.
    Transforms the path according to this matrix.
    
    """
    
    matrix = get_attribute(e, "transform", default="")
    if matrix.startswith("matrix("):
        
        matrix = matrix.replace("matrix(", "").rstrip(")")
        matrix = matrix.split(",")
        matrix = [float(v) for v in matrix]
    
        from nodebox.graphics import Transform
        t = Transform()
        t._set_matrix(matrix)
        path = t.transformBezierPath(path)
        
    return path
开发者ID:imclab,项目名称:odk-localdata,代码行数:24,代码来源:__init__.py


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