似乎是一个非常合理的问题。很惊讶没有答案。我最近不得不自己做这个,秘诀是point()
。
以下是我完成它的方法,使用您的样板作为起点:
from svgpathtools import Path, Line, CubicBezier
bezier_curve = CubicBezier(start=(300+100j), control1=(100+100j), control2=(200+200j), end=(200+300j))
bezier_path = Path(bezier_curve)
NUM_SAMPLES = 10
myPath = []
for i in range(NUM_SAMPLES):
myPath.append(bezier_path.point(i/(NUM_SAMPLES-1)))
print(myPath)
输出:
[(300+100j), (243.8957475994513+103.56652949245542j), (206.72153635116598+113.71742112482853j), (185.1851851851852+129.62962962962962j), (175.99451303155004+150.480109739369j), (175.85733882030178+175.44581618655695j), (181.4814814814815+203.7037037037037j), (189.57475994513032+234.43072702331963j), (196.84499314128942+266.8038408779149j), (200+300j)]