Circle to Square to Triangle Morph with Color Fade

Loading...

Loading video...

Pro
0:00 / 0:00

Purpose: Demonstrate shape morphing and color interpolation using Manim.

1. Scene Overview

  • Scene Class: ShapeMorphScene (inherits from Scene).
  • Background Color: White (WHITE).
  • Camera: Default 2‑D camera, no movement.

2. Visual Elements

Element Description Parameters
Circle Blue circle, centered at the origin. Radius r = 2; Fill color BLUE; Stroke color BLUE
Square Morph target after the circle. Side length s = 2*sqrt(2) ≈ 2.828; Fill color will transition; Stroke color matches fill
Triangle Final morph target (equilateral, pointing upward). Side length a = 2*sqrt(3) ≈ 3.464; Vertices positioned so the shape stays centered; Fill color continues transition

3. Timing & Transitions

  • Total Duration: 8 seconds.
  • Morph 1 (Circle → Square): 3 seconds.
  • Morph 2 (Square → Triangle): 3 seconds.
  • Hold on Triangle: 2 seconds (static display).
  • Easing: Linear interpolation for both shape and color.
  • Color Transition: Continuous interpolation from BLUE to RED over the entire 6‑second morph period.

4. Animation Steps (Pseudo‑code)

class ShapeMorphScene(Scene):
    def construct(self):
        # Create initial circle
        circle = Circle(radius=2, color=BLUE, fill_opacity=1).move_to(ORIGIN)
        self.add(circle)
        
        # Define target square and triangle
        square = Square(side_length=2*sqrt(2), color=RED, fill_opacity=1).move_to(ORIGIN)
        triangle = RegularPolygon(n=3, side_length=2*sqrt(3), color=RED, fill_opacity=1).move_to(ORIGIN)
        
        # Morph circle -> square with continuous color change
        self.play(
            Transform(circle, square, run_time=3, rate_func=linear),
            circle.animate.set_color(interpolate_color(BLUE, RED, 0.5)),
        )
        
        # Morph square -> triangle with continued color change
        self.play(
            Transform(square, triangle, run_time=3, rate_func=linear),
            square.animate.set_color(interpolate_color(BLUE, RED, 1.0)),
        )
        
        # Hold on final triangle
        self.wait(2)

5. Mathematical Details

  • Area Equality (approximate):
    Circle area=πr2=π×2212.57\text{Circle area} = \pi r^2 = \pi \times 2^2 \approx 12.57
    Square side=Circle area222.828\text{Square side} = \sqrt{\text{Circle area}} \approx 2\sqrt{2} \approx 2.828
    Equilateral triangle side=43×Circle area233.464\text{Equilateral triangle side} = \sqrt{\frac{4}{\sqrt{3}} \times \text{Circle area}} \approx 2\sqrt{3} \approx 3.464
  • Color Interpolation: Linear blend between RGB values of BLUE (0,0,1) and RED (1,0,0).

6. Default Assumptions Used

  • All shapes are centered at the origin.
  • No additional background or foreground objects.
  • Linear easing for smooth, predictable morphing.
  • The animation ends after the final hold; no looping.
  • The scene uses the default resolution and frame rate of Manim (default 1080p, 30 fps).

Created By

Kang Liang (tiga)Kang Liang (tiga)

Description

The scene shows a blue circle morphing linearly into a square and then into an upward-pointing equilateral triangle, while the fill color transitions smoothly from blue to red over six seconds, followed by a two-second hold on the final triangle.

Created At

Dec 25, 2025, 02:55 PM

Tags

shape-morphingcolor-interpolationgeometry

Status

Completed
AI Model
openai/gpt-oss-120b