本文整理汇总了Python中AnyQt.QtGui.QPainterPath.addLine方法的典型用法代码示例。如果您正苦于以下问题:Python QPainterPath.addLine方法的具体用法?Python QPainterPath.addLine怎么用?Python QPainterPath.addLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtGui.QPainterPath
的用法示例。
在下文中一共展示了QPainterPath.addLine方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: qpainterpath_simple_split
# 需要导入模块: from AnyQt.QtGui import QPainterPath [as 别名]
# 或者: from AnyQt.QtGui.QPainterPath import addLine [as 别名]
def qpainterpath_simple_split(path, t):
"""
Split a QPainterPath defined simple curve.
The path must be either empty or composed of a single LineToElement or
CurveToElement.
Parameters
----------
path : QPainterPath
t : float
Point where to split specified as a percentage along the path
Returns
-------
splitpath: Tuple[QPainterPath, QPainterPath]
A pair of QPainterPaths
"""
assert path.elementCount() > 0
el0 = path.elementAt(0)
assert el0.type == QPainterPath.MoveToElement
if path.elementCount() == 1:
p1 = QPainterPath()
p1.moveTo(el0.x, el0.y)
return p1, QPainterPath(p1)
el1 = path.elementAt(1)
if el1.type == QPainterPath.LineToElement:
pointat = path.pointAtPercent(t)
l1 = QLineF(el0.x, el0.y, pointat.x(), pointat.y())
l2 = QLineF(pointat.x(), pointat.y(), el1.x, el1.y)
p1 = QPainterPath()
p2 = QPainterPath()
p1.addLine(l1)
p2.addLine(l2)
return p1, p2
elif el1.type == QPainterPath.CurveToElement:
c0, c1, c2, c3 = el0, el1, path.elementAt(2), path.elementAt(3)
assert all(el.type == QPainterPath.CurveToDataElement
for el in [c2, c3])
cp = [QPointF(el.x, el.y) for el in [c0, c1, c2, c3]]
first, second = bezier_subdivide(cp, t)
p1, p2 = QPainterPath(), QPainterPath()
p1.moveTo(first[0])
p1.cubicTo(*first[1:])
p2.moveTo(second[0])
p2.cubicTo(*second[1:])
return p1, p2
else:
assert False