Skip to content

code #131

Description

@ranchanrat41-cmyk

from manim import *

class MathSummation(Scene):
def construct(self):
# Title
title = Text("Math Summation", font_size=48).to_edge(UP)
self.play(Write(title))

    # Step 1: Show equation
    equation1 = MathTex("1", "+", "2", "+", "3", "+", "4", "=", "10")
    equation1.scale(1.5)
    self.play(Write(equation1))
    self.wait(1)

    # Step 2: Highlight parts
    self.play(equation1[0].animate.set_color(RED))   # "1"
    self.play(equation1[2].animate.set_color(BLUE))  # "2"
    self.play(equation1[4].animate.set_color(GREEN)) # "3"
    self.play(equation1[6].animate.set_color(ORANGE))# "4"
    self.wait(1)

    # Step 3: Transform into summation form
    summation = MathTex(r"\sum_{n=1}^{4} n = 10")
    summation.scale(1.5)
    self.play(Transform(equation1, summation))
    self.wait(2)

    # Step 4: Fade out
    self.play(FadeOut(equation1), FadeOut(title))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions