mirror of
https://github.com/3b1b/manim.git
synced 2025-04-13 09:47:07 +00:00
56 lines
1.3 KiB
Python
56 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
from manimlib.constants import BLACK, GREY_E
|
|
from manimlib.constants import FRAME_HEIGHT
|
|
from manimlib.mobject.geometry import Rectangle
|
|
|
|
from typing import TYPE_CHECKING
|
|
if TYPE_CHECKING:
|
|
from manimlib.typing import ManimColor
|
|
|
|
|
|
class ScreenRectangle(Rectangle):
|
|
def __init__(
|
|
self,
|
|
aspect_ratio: float = 16.0 / 9.0,
|
|
height: float = 4,
|
|
**kwargs
|
|
):
|
|
super().__init__(
|
|
width=aspect_ratio * height,
|
|
height=height,
|
|
**kwargs
|
|
)
|
|
|
|
|
|
class FullScreenRectangle(ScreenRectangle):
|
|
def __init__(
|
|
self,
|
|
height: float = FRAME_HEIGHT,
|
|
fill_color: ManimColor = GREY_E,
|
|
fill_opacity: float = 1,
|
|
stroke_width: float = 0,
|
|
**kwargs,
|
|
):
|
|
super().__init__(
|
|
height=height,
|
|
fill_color=fill_color,
|
|
fill_opacity=fill_opacity,
|
|
stroke_width=stroke_width,
|
|
**kwargs
|
|
)
|
|
|
|
|
|
class FullScreenFadeRectangle(FullScreenRectangle):
|
|
def __init__(
|
|
self,
|
|
stroke_width: float = 0.0,
|
|
fill_color: ManimColor = BLACK,
|
|
fill_opacity: float = 0.7,
|
|
**kwargs,
|
|
):
|
|
super().__init__(
|
|
stroke_width=stroke_width,
|
|
fill_color=fill_color,
|
|
fill_opacity=fill_opacity,
|
|
)
|