Golden Thumb

1-on-1 tutor for math & coding
正文

A Student’s Animation with Manim

(2025-04-28 10:54:02) 下一個

Nicole, my 8th-grade student, had never used Manim or coded a video before.
But in just a few days, she made this beautiful animation — spelling out her name, stroke by stroke, with a dancing dot.

Every line, arc, and circle in the animation came from code she wrote herself.
She had to think geometrically, visualize paths, and experiment with timing.

Here’s what I loved most:
She kept tweaking the shape of the letter “e” until it felt just right to her eyes.
That’s not just code — that’s care.

And that’s how a dot becomes alive.
Not by magic, but by math, motion, and a student’s quiet creativity.
====

%%manim -ql NameWriting

class NameWriting(Scene):
    def construct(self):
        s = 0.7

        #N
        lineN = Line([-6, -2, 0], [-6, 2, 0]).shift(RIGHT*s)
        lineN1 = Line([-6, 2, 0], [-3, -2, 0]).shift(RIGHT*s)
        lineN2 = Line([-3, -2, 0], [-3, 2, 0]).shift(RIGHT*s)
        self.add(lineN, lineN1, lineN2)
        
        #i
        lineI = Line([-2.5, 0, 0], [-2.5, -2, 0]).shift(RIGHT*s)
        dotI = Dot().move_to([-2.5, 0.25, 0]).shift(RIGHT*s)
        self.add(lineI, dotI)
        
        #c
        arcC = Arc(start_angle=57*DEGREES, angle=250*DEGREES, radius=1).move_to([-1.25, -1, 0]).shift(RIGHT*s)
        self.add(arcC)
        
        #o
        circleO = Circle(radius=1, color=WHITE).move_to([0.75, -1, 0]).shift(RIGHT*s)
        self.add(circleO)
        
        #l
        lineL = Line([2.2, 2, 0], [2.2, -2, 0]).shift(RIGHT*s)
        self.add(lineL)
        
        #e
        lineE = Line([2.72, -0.75, 0], [4.65, -0.75, 0]).shift(RIGHT*s)
        arcE = Arc(start_angle=15*DEGREES, angle=320*DEGREES, radius=1).move_to([3.653, -1, 0]).shift(RIGHT*s)
        self.add(lineE, arcE)
        
        self.wait(1.5)

        # Animate the dot
        dotI2 = dotI.copy().move_to([-6, -2, 0]).shift(RIGHT*s)
        self.play(Transform(dotI, dotI2))

        self.play(MoveAlongPath(dotI, lineN), run_time=2)
        self.play(MoveAlongPath(dotI, lineN1), run_time=2)
        self.play(MoveAlongPath(dotI, lineN2), run_time=2)
        self.play(MoveAlongPath(dotI, lineI), run_time=2)
        self.play(MoveAlongPath(dotI, arcC), run_time=2)
        self.play(MoveAlongPath(dotI, circleO), run_time=2)
        self.play(MoveAlongPath(dotI, lineL), run_time=2)
        self.play(MoveAlongPath(dotI, lineE), run_time=2)
        self.play(MoveAlongPath(dotI, arcE), run_time=2)

        dotI3 = dotI.copy().move_to([-2.5, 0.25, 0]).shift(RIGHT*s)
        self.play(Transform(dotI, dotI3))
        self.add(dotI3)
        self.wait(2)
====
Even a beginner, with just math and code, can create something personal and beautiful.
Stories like this make me believe in the long journey ahead.

[ 打印 ]
評論
目前還沒有任何評論
登錄後才可評論.