Fast Typewriter Quiz: Four Square Number Challenges

Loading...

Loading video...

Pro
0:00 / 0:00

Animation Specification for 20‑second Math Shorts (9:16, 1080×1920)

Overall Settings

  • Resolution: 1080 × 1920 (vertical Full HD, 9:16)
  • Background: solid black (#000000).
  • Text color: white (#FFFFFF).
  • Font: a clean sans‑serif (e.g., OpenSans or Manim’s default Helvetica).
  • Audio: No background music; only a short type‑writer click sound for each character.
  • Camera: static (no pan/zoom).
  • Total video length: 20 s (4 s per question + 0.5 s fade transition between questions).

Scene Structure

The video consists of a single Scene (or ThreeDScene if you prefer, but a 2‑D Scene is sufficient) that sequentially presents the four multiple‑choice questions.

1. Global Constants (Python variables)

# Timing (seconds)
QUESTION_TIME = 4          # time the whole question block stays on screen
FADE_TIME = 0.5           # cross‑fade between questions
TYPE_SPEED = 0.04         # seconds per character for type‑writer effect
OPTION_DELAY = 0.3        # delay between successive answer options

2. Helper Functions

from manim import *

class Typewriter(VGroup):
    """Creates a type‑writer animation for a given TextMobject.
    Plays a click sound for each character.
    """
    def __init__(self, text, **kwargs):
        super().__init__(**kwargs)
        self.text = Text(text, **kwargs).scale(0.8)
        self.add(self.text)
        self.char_mobs = self.text.submobjects
        self.sound = "typewriter_click.mp3"  # provide a short click sound file in the media folder

    def get_animation(self):
        return AnimationGroup(*[
            Succession(
                Write(char, run_time=TYPE_SPEED, rate_func=linear),
                Audio(self.sound, gain=-5)  # lower volume if needed
            )
            for char in self.char_mobs
        ], lag_ratio=0)

3. Question Layout

Each question is displayed as a VGroup containing:

  1. Question line (large font, centered).
  2. Four answer options (A‑D) placed vertically, left‑aligned, with a small vertical gap.
def make_question(q_text, options):
    """Return a VGroup with the question and its four options.
    `options` is a list of strings like ["a) 59", "b) 64", ...]
    """
    q = Text(q_text, font_size=48, color=WHITE).to_edge(UP, buff=0.5)
    opt_mobs = []
    for i, opt in enumerate(options):
        opt_mob = Text(opt, font_size=42, color=WHITE)
        opt_mob.next_to(q, DOWN, buff=0.4 + i*0.6)
        opt_mobs.append(opt_mob)
    return VGroup(q, *opt_mobs)

4. Questions Data

questions = [
    {
        "q": "Find the square number?",
        "opts": ["a) 59", "b) 64", "c) 82", "d) 1000"],
    },
    {
        "q": "\(\sqrt{25600}\) has _____ digits?",
        "opts": ["a) 2", "b) 3", "c) 4", "d) 5"],
    },
    {
        "q": "$2^8 + 2^{15} + 2^n$ is a square number. Value of $n$?",
        "opts": ["a) 15", "b) 20", "c) 16", "d) 30"],
    },
    {
        "q": "Which one is a square number?",
        "opts": ["a) (14!·15!)/2", "b) (16!·15!)/2", "c) (16!·17!)/2", "d) (17!·18!)/2"],
    },
]

5. Main Scene

class MathShorts(Scene):
    def construct(self):
        self.camera.background_color = BLACK
        for i, data in enumerate(questions):
            # Build the VGroup for the current question
            q_group = make_question(data["q"], data["opts"]).move_to(ORIGIN)

            # ---- TYPEWRITER ANIMATION ----
            # 1) type the question line
            question_line = q_group[0]
            self.play(Typewriter(question_line).get_animation())
            self.wait(0.2)  # short pause before options start

            # 2) sequentially type each option
            for opt in q_group[1:]:
                self.play(Typewriter(opt).get_animation())
                self.wait(OPTION_DELAY)

            # Keep the whole block on screen for the remainder of the 4‑second window
            elapsed = (len(question_line.submobjects) * TYPE_SPEED +
                       len(q_group[1:]) * (TYPE_SPEED + OPTION_DELAY) + 0.2)
            remaining = max(0, QUESTION_TIME - elapsed)
            self.wait(remaining)

            # ---- FADE TO NEXT QUESTION (except after the last one) ----
            if i < len(questions) - 1:
                self.play(FadeOut(q_group, run_time=FADE_TIME))
                self.wait(FADE_TIME)  # small pause before next question appears
        # End of video – hold last frame for a moment
        self.wait(1)

6. Assets

  • typewriter_click.mp3 – a short click/typing sound (≈0.05 s). Place it in the project’s media/sounds/ folder.

7. Rendering Command

manim -pqh 1080x1920 math_shorts.py MathShorts

Explanation of Timing

  • Typewriter effect: each character appears with a 0.04 s delay, accompanied by the click sound.
  • Sequential options: after the question line finishes, each answer choice appears one after another with a 0.3 s pause.
  • Fade transition: a 0.5 s cross‑fade (FadeOut of the current VGroup and FadeIn of the next) separates the four blocks.
  • Total runtime: 4 s × 4 questions = 16 s + 3 × 0.5 s transitions = 17.5 s + 1 s final hold ≈ 18.5 s (rounded to 20 s with a 1.5 s final pause if desired).

Result: The specification above is complete and can be used directly to generate the requested 20‑second vertical math‑shorts video.

Created By

araf haquearaf haque

Description

An engaging 20‑second vertical video presents four multiple‑choice questions about square numbers. Each question and its answer options appear with a typewriter animation and click sound, followed by a brief pause and a smooth fade to the next question. Black background and white text ensure clear readability.

Created At

Dec 29, 2025, 04:00 PM

Tags

math-quiznumber-theorysquare-numbers

Status

Completed
AI Model
openai/gpt-oss-120b