11from __future__ import annotations
22
33import collections
4+ from collections .abc import Iterable , Sequence
5+ from typing import TYPE_CHECKING
46
57import numpy as np
68
9+ if TYPE_CHECKING :
10+ from manim .renderer .opengl_renderer import (
11+ OpenGLRenderer ,
12+ OpenGLVMobject ,
13+ )
14+ from manim .typing import MatrixMN
15+
716from ..utils import opengl
817from ..utils .space_ops import cross2d , earclip_triangulation
918from .shader import Shader
1423]
1524
1625
17- def build_matrix_lists (mob ):
26+ def build_matrix_lists (
27+ mob : OpenGLVMobject ,
28+ ) -> collections .defaultdict [tuple [float , ...], list [OpenGLVMobject ]]:
1829 root_hierarchical_matrix = mob .hierarchical_model_matrix ()
1930 matrix_to_mobject_list = collections .defaultdict (list )
2031 if mob .has_points ():
@@ -36,15 +47,21 @@ def build_matrix_lists(mob):
3647 return matrix_to_mobject_list
3748
3849
39- def render_opengl_vectorized_mobject_fill (renderer , mobject ):
50+ def render_opengl_vectorized_mobject_fill (
51+ renderer : OpenGLRenderer , mobject : OpenGLVMobject
52+ ) -> None :
4053 matrix_to_mobject_list = build_matrix_lists (mobject )
4154
4255 for matrix_tuple , mobject_list in matrix_to_mobject_list .items ():
4356 model_matrix = np .array (matrix_tuple ).reshape ((4 , 4 ))
4457 render_mobject_fills_with_matrix (renderer , model_matrix , mobject_list )
4558
4659
47- def render_mobject_fills_with_matrix (renderer , model_matrix , mobjects ):
60+ def render_mobject_fills_with_matrix (
61+ renderer : OpenGLRenderer ,
62+ model_matrix : MatrixMN ,
63+ mobjects : Iterable [OpenGLVMobject ],
64+ ) -> None :
4865 # Precompute the total number of vertices for which to reserve space.
4966 # Note that triangulate_mobject() will cache its results.
5067 total_size = 0
@@ -98,7 +115,7 @@ def render_mobject_fills_with_matrix(renderer, model_matrix, mobjects):
98115 vbo .release ()
99116
100117
101- def triangulate_mobject (mob ) :
118+ def triangulate_mobject (mob : OpenGLVMobject ) -> np . ndarray :
102119 if not mob .needs_new_triangulation :
103120 return mob .triangulation
104121
@@ -192,14 +209,20 @@ def triangulate_mobject(mob):
192209 return attributes
193210
194211
195- def render_opengl_vectorized_mobject_stroke (renderer , mobject ):
212+ def render_opengl_vectorized_mobject_stroke (
213+ renderer : OpenGLRenderer , mobject : OpenGLVMobject
214+ ) -> None :
196215 matrix_to_mobject_list = build_matrix_lists (mobject )
197216 for matrix_tuple , mobject_list in matrix_to_mobject_list .items ():
198217 model_matrix = np .array (matrix_tuple ).reshape ((4 , 4 ))
199218 render_mobject_strokes_with_matrix (renderer , model_matrix , mobject_list )
200219
201220
202- def render_mobject_strokes_with_matrix (renderer , model_matrix , mobjects ):
221+ def render_mobject_strokes_with_matrix (
222+ renderer : OpenGLRenderer ,
223+ model_matrix : MatrixMN ,
224+ mobjects : Sequence [OpenGLVMobject ],
225+ ) -> None :
203226 # Precompute the total number of vertices for which to reserve space.
204227 total_size = 0
205228 for submob in mobjects :
0 commit comments