本文整理汇总了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
示例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