""" 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() // এমন একটা ট্যামপ্লেট তৈরি করে দাও ভিন্ন ক্যাটা গরির এবং ভিন্ন ডিজািনের
নিচে তোমার প্রদত্ত HeatmapIntensityTemplate-এর একটি ভিন্ন ক্যাটাগরি ও ডিজাইন-যুক্ত ম্যানিম (Manim) টেমপ্লেট দেওয়া হল। এটি উপস্থাপন, শিক্ষা বা বিভিন্ন সাইবার অ্যাক্টিভিটি বা আর্ট ভিজ্যুয়ালাইজেশনের জন্য উপযোগী।
from manim import *
import numpy as np
from typing import Dict, List, Any
class CyberPulseVisualization(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 cyber style
self.style = {
"primary": "#03DAC6", # Neon Cyan
"secondary": "#BB86FC", # Purple
"accent": "#FF0364", # Hot Pink
"neutral": "#E0E0E0", # Light Gray
"dark": "#0D0D0D", # Dark Black
"heat_high": "#FF0032", # Red
"heat_med": "#FFA500", # Orange
"heat_low": "#FFFF00", # Yellow
"glow": "#00FFF0" # Glow Blue
}
if "style" in self.dynamic_data:
self.style.update(self.dynamic_data["style"])
def create_cyber_grid(self):
grid = VGroup()
if self.aspect_ratio == "9:16":
x_range, y_range = range(-3, 4), range(-5, 6)
elif self.aspect_ratio == "1:1":
x_range, y_range = range(-4, 5), range(-4, 5)
else:
x_range, y_range = range(-6, 7), range(-3, 4)
for x in x_range:
for y in y_range:
cell = Square(
side_length=1,
stroke_color=self.style["primary"],
stroke_width=0.5,
stroke_opacity=0.2
).move_to([x, y, 0])
grid.add(cell)
return grid
def create_heat_points(self, data):
points = VGroup()
for d in data:
intensity = d["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.7, fill_color=color, fill_opacity=0.6)
pulse = circle.copy().scale(1.5).set_opacity(0.2)
points.add(VGroup(circle, pulse))
circle.move_to(d["pos"])
pulse.move_to(d["pos"])
return points
def create_pulse_meter(self, value, label, font_size=24):
meter = VGroup()
radius = 1.2 if self.aspect_ratio != "9:16" else 0.9
bg_arc = Arc(radius=radius, angle=PI, stroke=self.style["neutral"], stroke_width=4, opacity=0.2)
val_arc = Arc(radius=radius, angle=PI * value, stroke=self.style["accent"], stroke_width=6)
label_text = Text(label, font="Arial", font_size=font_size, color=self.style["primary"]).next_to(bg_arc, DOWN)
percent = Text(f"{int(value*100)}%", font="Arial Bold", font_size=font_size+4, color=self.style["accent"]).move_to(bg_arc)
meter.add(bg_arc, val_arc, label_text, percent)
return meter
def construct(self):
config.background_color = self.style["dark"]
title = self.dynamic_data.get("title", "Cyber Pulse 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": "Security"},
{"value": 0.75, "label": "Activity"},
{"value": 0.92, "label": "Risk"}
])
title_font_size = self.dynamic_data.get("title_font_size", 60)
meter_font_size = self.dynamic_data.get("meter_font_size", 24)
# --- Title ---
title_mob = Text(title, font="Arial Bold", font_size=title_font_size, color=self.style["primary"])
title_mob.to_edge(UP, buff=0.5)
# --- Grid & Heat Points ---
grid = self.create_cyber_grid()
heat_points = self.create_heat_points(heat_data)
heat_map = VGroup(grid, heat_points).center()
# --- Meters ---
meters = VGroup(*[self.create_pulse_meter(m["value"], m["label"], meter_font_size) for m in meters_data])
if self.aspect_ratio == "9:16":
meters.arrange(DOWN, buff=1).to_edge(LEFT, buff=0.5)
else:
meters.arrange(RIGHT, buff=2).to_edge(DOWN, buff=1)
# --- Data Streams ---
streams = VGroup()
n_streams = min(len(heat_points), len(meters))
for i in range(n_streams):
start = heat_points[i].get_center()
end = meters[i].get_top()
path = CubicBezier(start, start + UP * 2, end + LEFT * 2, end)
glow = path.copy().set_stroke(self.style["glow"], width=6, opacity=0.3)
stream = VGroup(glow, path)
streams.add(stream)
# --- Animation Steps ---
steps = [
{"name": "title", "weight": 1},
{"name": "grid", "weight": 1},
{"name": "points", "weight": len(heat_points)},
{"name": "meters", "weight": len(meters)},
{"name": "streams", "weight": n_streams},
{"name": "final", "weight": 1},
{"name": "wait", "weight": 0.5}
]
total_weight = sum(s["weight"] for s in steps)
durations = [(s["weight"] / total_weight) * self.duration for s in steps]
# Play animations
self.play(Write(title_mob), run_time=durations[0])
self.play(FadeIn(grid), run_time=durations[1])
point_time = durations[2] / max(1, len(heat_points))
for p in heat_points:
self.play(FadeIn(p), run_time=point_time)
meter_time = durations[3] / max(1, len(meters))
for m in meters:
self.play(Create(m[0]), Create(m[1]), Write(m[2]), FadeIn(m[3]), run_time=meter_time)
stream_time = durations[4] / max(1, n_streams)
for s in streams:
self.play(Create(s[0]), Create(s[1]), run_time=stream_time)
self.play(
*[Flash(point=p[0].get_center(), color=p[0].get_color(), flash_radius=0.3) for p in heat_points],
self.camera.frame.animate.scale(1.1),
run_time=durations[5]
)
# Heat animation loop
def update_pulsing(obj, dt):
obj.time += dt
scale = 1 + 0.1 * np.sin(obj.time * 4)
obj.set_width(obj.base_width * scale)
obj.set_opacity(0.6 + 0.2 * np.sin(obj.time * 4))
for p in heat_points:
p[0].base_width = p[0].get_width()
p[0].time = 0
p[0].add_updater(update_pulsing)
self.wait(durations[6])
for p in heat_points:
p[0].remove_updater(update_pulsing)
# Example usage:
if __name__ == "__main__":
from manim import config
config.media_width = "100%"
scene = CyberPulseVisualization(
dynamic_data={
"title": "Cyber Threat Map",
"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": [
{"value": 0.85, "label": "Threat Level"},
{"value": 0.75, "label": "User Activity"},
{"value": 0.92, "label": "Network Risk"}
],
"title_font_size": 72,
"meter_font_size": 30
},
duration=12,
aspect_ratio="16:9"
)
scene.render()
Manim ইনস্টল করুন:
pip install manim
কোডটি .py ফাইলে সেভ করুন, যেমন cyber_visual.py
রেন্ডার করুন:
manim -pql cyber_visual.py CyberPulseVisualization
আশা করছি এই নতুন টেমপ্লেটটি তোমার প্রয়োজনের সাথে মানানসই হবে! আরও কোনো ডিজাইন বা থিম চাইলে বলো — তৈরি করে দেবো।