""" Title: Heatmap Intensity Template Description: A reusable Manim template for…
- User
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
""" Title: Heatmap Intensity Template
Description: A reusable Manim template for visualizing intensity, metrics, or activity using dynamic heat maps, meters, and data streams. All data, labels, and styles are configurable via dynamic_data. Animation duration is precisely controlled.
Expected dynamic_data format: { "title": str, # Scene title "heat_data": List[{"pos": [x, y, z], "intensity": float}], "meters": List[{"value": float, "label": str}], "style": Dict[str, str], # Optional style overrides "title_font_size": int, "meter_font_size": int, ... }
Tags:
from manim import * import numpy as np from typing import Dict, List, Any
class HeatmapIntensityTemplate(MovingCameraScene): def init(self, dynamic_data: Dict = {}, duration: int = 10, aspect_ratio: str = "16:9", **kwargs): super().init(**kwargs) self.dynamic_data = dynamic_data self.duration = duration self.aspect_ratio = aspect_ratio # Default style self.style = { "primary": "#00BCD4", # Cyan "secondary": "#FF4081", # Pink "accent": "#FFEB3B", # Yellow "neutral": "#FAFAFA", # White "dark": "#1A1A1A", # Almost Black "heat_high": "#FF0000", # Red "heat_med": "#FF8C00", # Orange "heat_low": "#FFD700", # Gold "glow": "#80DEEA" # Light Cyan } # Allow style override if "style" in self.dynamic_data: self.style.update(self.dynamic_data["style"])
def create_heat_map(self, data_points: List[Dict]) -> VGroup:
"""Creates an animated heat map with glowing effects."""
heat_map = VGroup()
# Background grid
grid = VGroup()
if self.aspect_ratio == "9:16":
x_range, y_range = range(-2, 3), range(-4, 5)
elif self.aspect_ratio == "1:1":
x_range, y_range = range(-3, 4), range(-3, 4)
else: # "16:9"
x_range, y_range = range(-4, 5), range(-2, 3)
for x in x_range:
for y in range(-2, 3):
cell = Square(
side_length=1,
stroke_color=self.style["primary"],
stroke_width=1,
stroke_opacity=0.3
).move_to([x, y, 0])
grid.add(cell)
# Heat points with intensity
heat_points = VGroup()
for point in data_points:
# Main heat circle
intensity = point["intensity"]
color = self.style["heat_high"] if intensity > 0.7 else \
self.style["heat_med"] if intensity > 0.4 else \
self.style["heat_low"]
circle = Circle(
radius=intensity * 0.8,
fill_color=color,
fill_opacity=0.6,
stroke_width=0
).move_to(point["pos"])
# Pulsing effect
pulses = VGroup()
for i in range(3):
pulse = circle.copy()
pulse.scale(1 + i * 0.3)
pulse.set_opacity(0.3 - i * 0.1)
pulses.add(pulse)
heat_points.add(VGroup(circle, pulses))
heat_map.add(grid, heat_points)
return heat_map
def create_data_stream(self, start: np.ndarray, end: np.ndarray) -> VGroup:
"""Creates flowing data stream effect."""
stream = VGroup()
# Main path
path = CubicBezier(
start,
start + UP + RIGHT,
end + DOWN + LEFT,
end
)
# Particle system
particles = VGroup()
for i in range(10):
alpha = i / 10
particle = Dot(
radius=0.05,
color=self.style["accent"],
fill_opacity=0.8
).move_to(path.point_from_proportion(alpha))
particles.add(particle)
# Path glow
glow = path.copy().set_stroke(
self.style["glow"],
width=8,
opacity=0.3
)
stream.add(glow, path, particles)
return stream
def create_intensity_meter(self, value: float, label: str, font_size: int = 24) -> VGroup:
"""Creates an animated intensity meter."""
meter = VGroup()
if self.aspect_ratio == "9:16":
meter_radius = 0.7
elif self.aspect_ratio == "1:1":
meter_radius = 0.85
else: # "16:9"
meter_radius = 1.0
# Background arc
bg_arc = Arc(
radius=meter_radius,
angle=PI,
stroke_color=self.style["neutral"],
stroke_width=4,
stroke_opacity=0.3
)
# Value arc
value_arc = Arc(
radius=meter_radius,
angle=PI * value,
stroke_color=self.style["accent"],
stroke_width=6
)
# Label
text = Text(
label,
font="Arial Bold",
font_size=font_size,
color=self.style["neutral"]
).next_to(bg_arc, DOWN, buff=0.3)
# Value display
value_text = Text(
f"{int(value * 100)}%",
font="Arial Black",
font_size=font_size + 8,
color=self.style["accent"]
).move_to(bg_arc)
meter.add(bg_arc, value_arc, text, value_text)
return meter
def construct(self):
"""Constructs the scene with dynamic battle intensity visualization."""
# --- Aspect Ratio Config ---
if self.aspect_ratio == "9:16":
config.pixel_width, config.pixel_height = 1080, 1920
config.frame_width, config.frame_height = 9, 16
elif self.aspect_ratio == "1:1":
config.pixel_width, config.pixel_height = 1080, 1080
config.frame_width, config.frame_height = 8, 8
else: # "16:9"
config.pixel_width, config.pixel_height = 1920, 1080
config.frame_width, config.frame_height = 16, 9
# --- Extract dynamic data with defaults ---
title = self.dynamic_data.get("title", "Heatmap Intensity Analysis")
heat_data = self.dynamic_data.get("heat_data", [
{"pos": [-2, 1, 0], "intensity": 0.9},
{"pos": [1, -1, 0], "intensity": 0.7},
{"pos": [-1, -1, 0], "intensity": 0.5},
{"pos": [2, 1, 0], "intensity": 0.8}
])
meters_data = self.dynamic_data.get("meters", [
{"value": 0.85, "label": "Metric 1"},
{"value": 0.75, "label": "Metric 2"},
{"value": 0.92, "label": "Metric 3"}
])
title_font_size = self.dynamic_data.get("title_font_size", 48)
meter_font_size = self.dynamic_data.get("meter_font_size", 24)
# --- Adjustments for Aspect Ratio ---
if self.aspect_ratio == "9:16":
title_font_size *= 0.7
meter_font_size *= 0.7
elif self.aspect_ratio == "1:1":
title_font_size *= 0.85
meter_font_size *= 0.85
# --- Create and layout elements ---
title_mob = Text(
title,
font="Arial Black",
font_size=title_font_size,
color=self.style["primary"]
)
heat_map = self.create_heat_map(heat_data)
meters = VGroup(*[
self.create_intensity_meter(
m["value"], m["label"], meter_font_size)
for m in meters_data
])
if self.aspect_ratio == "9:16":
title_mob.to_edge(UP, buff=0.5)
meters.arrange(DOWN, buff=0.5).to_edge(LEFT, buff=0.5)
heat_map.to_edge(RIGHT, buff=0.5)
elif self.aspect_ratio == "1:1":
title_mob.to_edge(UP, buff=0.8)
meters.arrange(RIGHT, buff=0.5).to_edge(DOWN, buff=1)
else: # "16:9"
title_mob.to_edge(UP, buff=0.8)
meters.arrange(RIGHT, buff=1.5).to_edge(DOWN, buff=1)
# Data streams: match up to min(len(heat_points), len(meters))
n_streams = min(len(heat_map[1]), len(meters))
streams = VGroup(*[
self.create_data_stream(
heat_map[1][i][0].get_center(),
meters[i].get_top()
)
for i in range(n_streams)
])
self.camera.frame.save_state()
# --- Animation step weights ---
steps = [
{"name": "title", "weight": 1},
{"name": "grid", "weight": 1},
{"name": "heat_points", "weight": len(heat_map[1])},
{"name": "meters", "weight": len(meters)},
{"name": "streams", "weight": n_streams},
{"name": "final_emphasis", "weight": 1},
{"name": "final_wait", "weight": 0.5}
]
total_weight = sum(step["weight"] for step in steps)
for step in steps:
step["duration"] = (step["weight"] / total_weight) * self.duration
# --- Animation sequence ---
self.play(Write(title_mob), run_time=steps[0]["duration"])
self.play(Create(heat_map[0]), run_time=steps[1]["duration"])
# Heat points: split duration evenly among all points
heat_point_time = steps[2]["duration"] / max(1, len(heat_map[1]))
for point in heat_map[1]:
self.play(
FadeIn(point[0], scale=1.2),
*[FadeIn(pulse, scale=1.1) for pulse in point[1]],
run_time=heat_point_time
)
# Meters: split duration evenly among all meters, and split further for arc and label/value
meter_time = steps[3]["duration"] / max(1, len(meters))
for meter in meters:
self.play(
self.camera.frame.animate.scale(0.9).move_to(meter),
Create(meter[0]),
Create(meter[1]),
run_time=meter_time * 0.5
)
self.play(
Write(meter[2]),
FadeIn(meter[3], scale=1.1),
run_time=meter_time * 0.5
)
# Streams: split duration among all streams, and split further for path and particles
# Camera transition uses 20% of streams step, rest is for streams
self.play(
self.camera.frame.animate.scale(1.2).move_to(ORIGIN),
run_time=steps[4]["duration"] * 0.2
)
stream_time = (steps[4]["duration"] * 0.8) / max(1, n_streams)
for stream in streams:
self.play(
Create(stream[0]),
Create(stream[1]),
run_time=stream_time * 0.5
)
self.play(
LaggedStartMap(FadeIn, stream[2], lag_ratio=0.1),
run_time=stream_time * 0.5
)
self.play(
self.camera.frame.animate.scale(1.1),
*[
Flash(
point=point[0].get_center(),
color=point[0].get_color(),
line_length=0.5,
flash_radius=0.4,
num_lines=8
)
for point in heat_map[1]
],
run_time=steps[5]["duration"]
)
def heat_updater(mob, dt):
mob.time = getattr(mob, "time", 0) + dt
scale = 1 + 0.1 * np.sin(mob.time * 2)
mob.set_opacity(0.6 + 0.2 * np.sin(mob.time * 2))
mob.scale_to_fit_width(mob.initial_width * scale)
for point in heat_map[1]:
point[0].initial_width = point[0].get_width()
point[0].add_updater(heat_updater)
self.wait(steps[6]["duration"])
for point in heat_map[1]:
point[0].clear_updaters() // এমন একটা ট্যামপ্লেট তৈরি করে দাও ভিন্ন ক্যাটা গরির এবং ভিন্ন ডিজািনের
এখানে একটি সম্পূর্ণ ভিন্ন ক্যাটাগরি এবং ডিজাইনের টেমপ্লেট:
"""
Title: Timeline Chronicle Template
Description:
A cinematic Manim template for creating flowing timeline animations with events, milestones, and narratives.
Perfect for historical timelines, project roadmaps, story progressions, and educational content.
All events, styling, and transitions are fully configurable via dynamic_data.
Expected dynamic_data format:
{
"title": str, # Timeline title
"subtitle": str, # Optional subtitle
"events": List[{"year": str, "title": str, "description": str, "color": str}],
"timeline_style": str, # "flowing", "linear", "circular"
"theme": str, # "cosmic", "minimal", "vintage", "modern"
"show_particles": bool,
"title_font_size": int,
"event_font_size": int,
...
}
Tags:
- timeline
- chronicle
- storytelling
- educational
- narrative
- animation
- manim
- template
- cinematic
"""
from manim import *
import numpy as np
from typing import Dict, List, Any
import random
class TimelineChronicleTemplate(MovingCameraScene):
def __init__(self, dynamic_data: Dict = {}, duration: int = 15, aspect_ratio: str = "16:9", **kwargs):
super().__init__(**kwargs)
self.dynamic_data = dynamic_data
self.duration = duration
self.aspect_ratio = aspect_ratio
# Theme-based styling
self.themes = {
"cosmic": {
"primary": "#6A5ACD", # Slate Blue
"secondary": "#FF6347", # Tomato
"accent": "#20B2AA", # Light Sea Green
"background": "#0F0F23", # Deep Navy
"text": "#F0F8FF", # Alice Blue
"glow": "#9370DB", # Medium Purple
"timeline": "#4169E1" # Royal Blue
},
"minimal": {
"primary": "#2C3E50", # Dark Blue Gray
"secondary": "#E74C3C", # Red
"accent": "#F39C12", # Orange
"background": "#ECF0F1", # Light Gray
"text": "#2C3E50", # Dark Blue Gray
"glow": "#3498DB", # Blue
"timeline": "#34495E" # Dark Gray
},
"vintage": {
"primary": "#8B4513", # Saddle Brown
"secondary": "#CD853F", # Peru
"accent": "#DAA520", # Goldenrod
"background": "#F5F5DC", # Beige
"text": "#8B4513", # Saddle Brown
"glow": "#DEB887", # Burlywood
"timeline": "#A0522D" # Sienna
},
"modern": {
"primary": "#FF6B6B", # Coral
"secondary": "#4ECDC4", # Turquoise
"accent": "#45B7D1", # Sky Blue
"background": "#1A1A2E", # Dark Purple
"text": "#FFFFFF", # White
"glow": "#96CEB4", # Light Green
"timeline": "#FFEAA7" # Light Yellow
}
}
# Get theme
theme_name = self.dynamic_data.get("theme", "cosmic")
self.style = self.themes.get(theme_name, self.themes["cosmic"])
def create_flowing_timeline_path(self, num_points: int) -> ParametricFunction:
"""Creates a flowing, organic timeline path."""
timeline_style = self.dynamic_data.get("timeline_style", "flowing")
if timeline_style == "circular":
return ParametricFunction(
lambda t: np.array([
3 * np.cos(t),
3 * np.sin(t),
0
]),
t_range=[0, 2*PI]
)
elif timeline_style == "linear":
if self.aspect_ratio == "9:16":
return Line(UP * 6, DOWN * 6)
else:
return Line(LEFT * 6, RIGHT * 6)
else: # flowing
return ParametricFunction(
lambda t: np.array([
6 * (t - 0.5),
2 * np.sin(3 * t) * np.exp(-t),
0
]),
t_range=[0, 1]
)
def create_event_marker(self, event: Dict, position: np.ndarray, index: int) -> VGroup:
"""Creates an animated event marker with text and effects."""
marker_group = VGroup()
# Main marker circle
marker = Circle(
radius=0.3,
fill_color=event.get("color", self.style["accent"]),
fill_opacity=0.8,
stroke_color=self.style["glow"],
stroke_width=3
).move_to(position)
# Pulsing ring
ring = Circle(
radius=0.5,
stroke_color=event.get("color", self.style["accent"]),
stroke_width=2,
stroke_opacity=0.6,
fill_opacity=0
).move_to(position)
# Year label
year_text = Text(
event["year"],
font="Arial Bold",
font_size=self.dynamic_data.get("event_font_size", 24),
color=self.style["text"]
)
# Event title
title_text = Text(
event["title"],
font="Arial",
font_size=self.dynamic_data.get("event_font_size", 20),
color=self.style["text"]
)
# Description
desc_text = Text(
event["description"],
font="Arial",
font_size=self.dynamic_data.get("event_font_size", 16) - 4,
color=self.style["text"]
)
# Position text based on alternating sides
if index % 2 == 0:
# Right side
text_group = VGroup(year_text, title_text, desc_text).arrange(DOWN, aligned_edge=LEFT)
text_group.next_to(marker, RIGHT, buff=0.5)
else:
# Left side
text_group = VGroup(year_text, title_text, desc_text).arrange(DOWN, aligned_edge=RIGHT)
text_group.next_to(marker, LEFT, buff=0.5)
# Connection line
connection = Line(
marker.get_center(),
text_group.get_center(),
stroke_color=self.style["timeline"],
stroke_width=2,
stroke_opacity=0.7
)
marker_group.add(marker, ring, connection, text_group)
return marker_group
def create_particle_system(self, center: np.ndarray, count: int = 20) -> VGroup:
"""Creates floating particle effects."""
particles = VGroup()
for _ in range(count):
particle = Dot(
radius=random.uniform(0.02, 0.08),
color=random.choice([
self.style["accent"],
self.style["glow"],
self.style["secondary"]
]),
fill_opacity=random.uniform(0.3, 0.7)
)
# Random position around center
offset = np.array([
random.uniform(-4, 4),
random.uniform(-3, 3),
0
])
particle.move_to(center + offset)
particles.add(particle)
return particles
def create_background_elements(self) -> VGroup:
"""Creates atmospheric background elements."""
background = VGroup()
# Gradient background simulation with rectangles
for i in range(10):
rect = Rectangle(
width=config.frame_width,
height=config.frame_height / 10,
fill_color=self.style["background"],
fill_opacity=0.8 - i * 0.05,
stroke_width=0
).shift(UP * (config.frame_height/2 - i * config.frame_height/10))
background.add(rect)
# Floating geometric shapes
if self.dynamic_data.get("show_particles", True):
for _ in range(15):
shape_type = random.choice([Circle, Square, Triangle])
shape = shape_type(
radius=random.uniform(0.1, 0.3) if shape_type == Circle else None,
side_length=random.uniform(0.2, 0.6) if shape_type == Square else None,
fill_color=self.style["glow"],
fill_opacity=random.uniform(0.1, 0.3),
stroke_width=0
)
if shape_type == Triangle:
shape = Triangle(
fill_color=self.style["glow"],
fill_opacity=random.uniform(0.1, 0.3),
stroke_width=0
).scale(random.uniform(0.2, 0.6))
shape.move_to([
random.uniform(-8, 8),
random.uniform(-5, 5),
0
])
background.add(shape)
return background
def construct(self):
"""Constructs the cinematic timeline chronicle."""
# --- Aspect Ratio Config ---
if self.aspect_ratio == "9:16":
config.pixel_width, config.pixel_height = 1080, 1920
config.frame_width, config.frame_height = 9, 16
elif self.aspect_ratio == "1:1":
config.pixel_width, config.pixel_height = 1080, 1080
config.frame_width, config.frame_height = 8, 8
else: # "16:9"
config.pixel_width, config.pixel_height = 1920, 1080
config.frame_width, config.frame_height = 16, 9
# --- Extract dynamic data with defaults ---
title = self.dynamic_data.get("title", "Chronicle Timeline")
subtitle = self.dynamic_data.get("subtitle", "A Journey Through Time")
events_data = self.dynamic_data.get("events", [
{
"year": "2020",
"title": "The Beginning",
"description": "Where our story starts",
"color": self.style["secondary"]
},
{
"year": "2021",
"title": "First Milestone",
"description": "A significant achievement",
"color": self.style["accent"]
},
{
"year": "2022",
"title": "Major Breakthrough",
"description": "Revolutionary discovery",
"color": self.style["primary"]
},
{
"year": "2023",
"title": "New Horizons",
"description": "Expanding possibilities",
"color": self.style["glow"]
},
{
"year": "2024",
"title": "Present Day",
"description": "Current achievements",
"color": self.style["secondary"]
}
])
title_font_size = self.dynamic_data.get("title_font_size", 56)
event_font_size = self.dynamic_data.get("event_font_size", 24)
# --- Font size adjustments ---
if self.aspect_ratio == "9:16":
title_font_size *= 0.8
event_font_size *= 0.8
elif self.aspect_ratio == "1:1":
title_font_size *= 0.9
event_font_size *= 0.9
# --- Create elements ---
background = self.create_background_elements()
# Title and subtitle
title_mob = Text(
title,
font="Arial Black",
font_size=title_font_size,
color=self.style["text"]
)
subtitle_mob = Text(
subtitle,
font="Arial",
font_size=title_font_size - 16,
color=self.style["accent"]
).next_to(title_mob, DOWN, buff=0.3)
title_group = VGroup(title_mob, subtitle_mob)
# Timeline path
timeline_path = self.create_flowing_timeline_path(len(events_data))
timeline_path.set_stroke(
color=self.style["timeline"],
width=4,
opacity=0.8
)
# Event markers
events = VGroup()
for i, event in enumerate(events_data):
# Calculate position along timeline
if self.dynamic_data.get("timeline_style") == "circular":
alpha = i / len(events_data)
position = timeline_path.point_from_proportion(alpha)
else:
alpha = i / max(1, len(events_data) - 1) if len(events_data) > 1 else 0
position = timeline_path.point_from_proportion(alpha)
event_marker = self.create_event_marker(event, position, i)
events.add(event_marker)
# Particle systems
particles = VGroup()
if self.dynamic_data.get("show_particles", True):
for event in events:
particle_system = self.create_particle_system(event[0].get_center())
particles.add(particle_system)
# --- Position elements ---
if self.aspect_ratio == "9:16":
title_group.to_edge(UP, buff=1)
else:
title_group.to_edge(UP, buff=1.5)
# --- Animation timing ---
steps = [
{"name": "background", "weight": 1},
{"name": "title", "weight": 1.5},
{"name": "timeline_path", "weight": 2},
{"name": "events", "weight": len(events_data) * 1.5},
{"name": "particles", "weight": 1.5 if self.dynamic_data.get("show_particles", True) else 0},
{"name": "camera_tour", "weight": 3},
{"name": "final_emphasis", "weight": 2},
{"name": "final_wait", "weight": 1}
]
total_weight = sum(step["weight"] for step in steps if step["weight"] > 0)
for step in steps:
if step["weight"] > 0:
step["duration"] = (step["weight"] / total_weight) * self.duration
else:
step["duration"] = 0
# --- Animation sequence ---
# Background fade in
self.play(
FadeIn(background, lag_ratio=0.1),
run_time=steps[0]["duration"]
)
# Title entrance with cinematic effect
self.play(
Write(title_mob, lag_ratio=0.1),
run_time=steps[1]["duration"] * 0.6
)
self.play(
FadeIn(subtitle_mob, shift=UP*0.5),
run_time=steps[1]["duration"] * 0.4
)
# Timeline path creation
self.play(
Create(timeline_path),
run_time=steps[2]["duration"]
)
# Events appear one by one
event_time = steps[3]["duration"] / len(events_data)
for i, event in enumerate(events):
# Camera focus on event
self.play(
self.camera.frame.animate.scale(0.7).move_to(event[0]),
run_time=event_time * 0.2
)
# Event marker appears
self.play(
FadeIn(event[0], scale=1.3), # Main marker
Create(event[1]), # Ring
run_time=event_time * 0.3
)
# Connection and text
self.play(
Create(event[2]), # Connection line
FadeIn(event[3], shift=UP*0.3), # Text group
run_time=event_time * 0.5
)
# Particles appear
if steps[4]["duration"] > 0:
self.play(
LaggedStartMap(FadeIn, particles, lag_ratio=0.2),
run_time=steps[4]["duration"]
)
# Camera tour
self.play(
self.camera.frame.animate.scale(1.5).move_to(ORIGIN),
run_time=steps[5]["duration"]
)
# Final emphasis with flowing effects
self.play(
timeline_path.animate.set_stroke(width=6),
*[
Flash(
point=event[0].get_center(),
color=event[0].get_color(),
line_length=0.8,
flash_radius=0.6,
num_lines=12
)
for event in events
],
run_time=steps[6]["duration"]
)
# Add flowing animation to particles
if self.dynamic_data.get("show_particles", True):
def particle_updater(mob, dt):
mob.time = getattr(mob, "time", 0) + dt
for i, particle in enumerate(mob):
offset = 0.3 * np.sin(mob.time + i) * UP + 0.2 * np.cos(mob.time * 1.5 + i) * RIGHT
particle.shift(offset * dt)
for particle_system in particles:
particle_system.add_updater(particle_updater)
# Final wait
self.wait(steps[7]["duration"])
# Clear updaters
if self.dynamic_data.get("show_particles", True):
for particle_system in particles:
particle_system.clear_updaters()
এই টেমপ্লেটটি সম্পূর্ণ ভিন্ন:
ক্যাটাগরি পার্থক্য:
ডিজাইন পার্থক্য:
ভিজ্যুয়াল স্টাইল:
ব্যবহার: