所有 VMobject 本质上都是一串点,point_from_proportion(t) 按比例取路径上的点。示例先画一条线段,再让黄点依次停到 25%、50%、75% 的位置,直观看到参数与位置的对应关系。
完整代码
1 2 3 4 5 6 7 8 9 10 11 12
| from manim import * class MobjectPoints(Scene): def construct(self): line = Line(LEFT * 3, RIGHT * 3, color=BLUE) self.play(Create(line)) dot = Dot(line.get_start(), color=YELLOW) self.play(FadeIn(dot)) for alpha in (0.25, 0.5, 0.75): target = line.point_from_proportion(alpha) self.play(dot.animate.move_to(target), run_time=0.7) self.wait(1) self.wait(1.90)
|
演示视频
下载 Python 脚本
要点
point_from_proportion(0) 是起点,1 是终点,中间按弧长比例取点
get_start() / get_end() 只取两端,适合做连线
- 所有点存在
points 属性里,改点集后要重新 init_colors 才会刷新样式
代码来源:Manim Community 官方教程 Guides / Deep Dive,示例代码按 Manim CE 0.20.1 编写并实跑验证。
主观感受,仅供参考。本文采用 本文采用 CC BY-NC-SA 4.0 许可 协议,
完整转载请注明来自
数学动画引擎。