本文整理匯總了Python中PyQt5.Qt.QPainterPath.quadTo方法的典型用法代碼示例。如果您正苦於以下問題:Python QPainterPath.quadTo方法的具體用法?Python QPainterPath.quadTo怎麽用?Python QPainterPath.quadTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt5.Qt.QPainterPath
的用法示例。
在下文中一共展示了QPainterPath.quadTo方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: svg_path_to_painter_path
# 需要導入模塊: from PyQt5.Qt import QPainterPath [as 別名]
# 或者: from PyQt5.Qt.QPainterPath import quadTo [as 別名]
#.........這裏部分代碼省略.........
cmd = data.read(1) if repeated_command is None else repeated_command
repeated_command = None
if cmd == b' ':
continue
elif cmd == moveto_abs:
x, y = parse_float(), parse_float()
path.moveTo(x, y)
elif cmd == moveto_rel:
x += parse_float()
y += parse_float()
path.moveTo(x, y)
elif cmd == closepath1 or cmd == closepath2:
path.closeSubpath()
elif cmd == lineto_abs:
x, y = parse_floats(2)
path.lineTo(x, y)
elif cmd == lineto_rel:
x += parse_float()
y += parse_float()
path.lineTo(x, y)
elif cmd == hline_abs:
x = parse_float()
path.lineTo(x, y)
elif cmd == hline_rel:
x += parse_float()
path.lineTo(x, y)
elif cmd == vline_abs:
y = parse_float()
path.lineTo(x, y)
elif cmd == vline_rel:
y += parse_float()
path.lineTo(x, y)
elif cmd == curveto_abs:
x1, y1, x2, y2, x, y = parse_floats(6)
path.cubicTo(x1, y1, x2, y2, x, y)
elif cmd == curveto_rel:
x1, y1, x2, y2, x, y = parse_floats(6, x, y)
path.cubicTo(x1, y1, x2, y2, x, y)
elif cmd == smoothcurveto_abs:
if last_cmd == curveto_abs or last_cmd == curveto_rel or last_cmd == smoothcurveto_abs or last_cmd == smoothcurveto_rel:
x1 = 2 * x - x2
y1 = 2 * y - y2
else:
x1, y1 = x, y
x2, y2, x, y = parse_floats(4)
path.cubicTo(x1, y1, x2, y2, x, y)
elif cmd == smoothcurveto_rel:
if last_cmd == curveto_abs or last_cmd == curveto_rel or last_cmd == smoothcurveto_abs or last_cmd == smoothcurveto_rel:
x1 = 2 * x - x2
y1 = 2 * y - y2
else:
x1, y1 = x, y
x2, y2, x, y = parse_floats(4, x, y)
path.cubicTo(x1, y1, x2, y2, x, y)
elif cmd == quadcurveto_abs:
x1, y1, x, y = parse_floats(4)
path.quadTo(x1, y1, x, y)
elif cmd == quadcurveto_rel:
x1, y1, x, y = parse_floats(4, x, y)
path.quadTo(x1, y1, x, y)
elif cmd == smoothquadcurveto_abs:
if last_cmd in (quadcurveto_abs, quadcurveto_rel, smoothquadcurveto_abs, smoothquadcurveto_rel):
x1 = 2 * x - x1
y1 = 2 * y - y1
else:
x1, y1 = x, y
x, y = parse_floats(2)
path.quadTo(x1, y1, x, y)
elif cmd == smoothquadcurveto_rel:
if last_cmd in (quadcurveto_abs, quadcurveto_rel, smoothquadcurveto_abs, smoothquadcurveto_rel):
x1 = 2 * x - x1
y1 = 2 * y - y1
else:
x1, y1 = x, y
x, y = parse_floats(2, x, y)
path.quadTo(x1, y1, x, y)
elif cmd[0] in b'-.' or b'0' <= cmd[0] <= b'9':
# A new number begins
# In this case, multiple parameters tuples are specified for the last command
# We rewind to reparse data correctly
data.seek(-1, os.SEEK_CUR)
# Handle extra parameters
if last_cmd == moveto_abs:
repeated_command = cmd = lineto_abs
elif last_cmd == moveto_rel:
repeated_command = cmd = lineto_rel
elif last_cmd in (closepath1, closepath2):
raise ValueError('Extra parameters after close path command')
elif last_cmd in (
lineto_abs, lineto_rel, hline_abs, hline_rel, vline_abs,
vline_rel, curveto_abs, curveto_rel,smoothcurveto_abs,
smoothcurveto_rel, quadcurveto_abs, quadcurveto_rel,
smoothquadcurveto_abs, smoothquadcurveto_rel
):
repeated_command = cmd = last_cmd
else:
raise ValueError('Unknown path command: %s' % cmd)
return path