frame.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. from __future__ import annotations
  2. from manimlib.constants import BLACK, GREY_E
  3. from manimlib.constants import FRAME_HEIGHT
  4. from manimlib.mobject.geometry import Rectangle
  5. from typing import TYPE_CHECKING
  6. if TYPE_CHECKING:
  7. from manimlib.typing import ManimColor
  8. class ScreenRectangle(Rectangle):
  9. def __init__(
  10. self,
  11. aspect_ratio: float = 16.0 / 9.0,
  12. height: float = 4,
  13. **kwargs
  14. ):
  15. super().__init__(
  16. width=aspect_ratio * height,
  17. height=height,
  18. **kwargs
  19. )
  20. class FullScreenRectangle(ScreenRectangle):
  21. def __init__(
  22. self,
  23. height: float = FRAME_HEIGHT,
  24. fill_color: ManimColor = GREY_E,
  25. fill_opacity: float = 1,
  26. stroke_width: float = 0,
  27. **kwargs,
  28. ):
  29. super().__init__(
  30. height=height,
  31. fill_color=fill_color,
  32. fill_opacity=fill_opacity,
  33. stroke_width=stroke_width,
  34. )
  35. class FullScreenFadeRectangle(FullScreenRectangle):
  36. def __init__(
  37. self,
  38. stroke_width: float = 0.0,
  39. fill_color: ManimColor = BLACK,
  40. fill_opacity: float = 0.7,
  41. **kwargs,
  42. ):
  43. super().__init__(
  44. stroke_width=stroke_width,
  45. fill_color=fill_color,
  46. fill_opacity=fill_opacity,
  47. )