2022-02-15 18:39:45 +08:00
|
|
|
from __future__ import annotations
|
|
|
|
|
2019-02-10 10:26:29 -08:00
|
|
|
from manimlib.animation.composition import LaggedStart
|
|
|
|
from manimlib.animation.transform import Restore
|
2022-04-12 19:19:59 +08:00
|
|
|
from manimlib.constants import BLACK, WHITE
|
2018-12-24 12:37:51 -08:00
|
|
|
from manimlib.mobject.geometry import Circle
|
|
|
|
from manimlib.mobject.types.vectorized_mobject import VGroup
|
2018-03-31 18:05:02 -07:00
|
|
|
|
2022-04-12 19:19:59 +08:00
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
|
|
|
|
if TYPE_CHECKING:
|
|
|
|
import numpy as np
|
2022-12-16 20:19:18 -08:00
|
|
|
from manimlib.typing import ManimColor
|
2022-04-12 19:19:59 +08:00
|
|
|
|
2018-04-06 13:58:59 -07:00
|
|
|
|
2019-02-10 10:26:29 -08:00
|
|
|
class Broadcast(LaggedStart):
|
2022-12-14 15:13:30 -08:00
|
|
|
def __init__(
|
|
|
|
self,
|
|
|
|
focal_point: np.ndarray,
|
|
|
|
small_radius: float = 0.0,
|
|
|
|
big_radius: float = 5.0,
|
|
|
|
n_circles: int = 5,
|
|
|
|
start_stroke_width: float = 8.0,
|
|
|
|
color: ManimColor = WHITE,
|
|
|
|
run_time: float = 3.0,
|
|
|
|
lag_ratio: float = 0.2,
|
|
|
|
remover: bool = True,
|
|
|
|
**kwargs
|
|
|
|
):
|
|
|
|
self.focal_point = focal_point
|
|
|
|
self.small_radius = small_radius
|
|
|
|
self.big_radius = big_radius
|
|
|
|
self.n_circles = n_circles
|
|
|
|
self.start_stroke_width = start_stroke_width
|
|
|
|
self.color = color
|
2018-04-06 13:58:59 -07:00
|
|
|
|
2018-03-31 18:05:02 -07:00
|
|
|
circles = VGroup()
|
2022-12-14 15:13:30 -08:00
|
|
|
for x in range(n_circles):
|
2018-03-31 18:05:02 -07:00
|
|
|
circle = Circle(
|
2022-12-14 15:13:30 -08:00
|
|
|
radius=big_radius,
|
2018-04-06 13:58:59 -07:00
|
|
|
stroke_color=BLACK,
|
|
|
|
stroke_width=0,
|
2018-03-31 18:05:02 -07:00
|
|
|
)
|
2022-12-14 15:13:30 -08:00
|
|
|
circle.add_updater(lambda c: c.move_to(focal_point))
|
2018-03-31 18:05:02 -07:00
|
|
|
circle.save_state()
|
2022-12-14 15:13:30 -08:00
|
|
|
circle.set_width(small_radius * 2)
|
|
|
|
circle.set_stroke(color, start_stroke_width)
|
2018-03-31 18:05:02 -07:00
|
|
|
circles.add(circle)
|
2022-12-14 15:13:30 -08:00
|
|
|
super().__init__(
|
|
|
|
*map(Restore, circles),
|
|
|
|
run_time=run_time,
|
|
|
|
lag_ratio=lag_ratio,
|
|
|
|
remover=remover,
|
|
|
|
**kwargs
|
|
|
|
)
|