mirror of
https://github.com/3b1b/manim.git
synced 2025-11-15 21:17:45 +00:00
commit
aedde4dffc
4 changed files with 11 additions and 10 deletions
|
|
@ -81,7 +81,6 @@ class Matrix(VMobject):
|
||||||
bracket_v_buff: float = 0.25,
|
bracket_v_buff: float = 0.25,
|
||||||
add_background_rectangles_to_entries: bool = False,
|
add_background_rectangles_to_entries: bool = False,
|
||||||
include_background_rectangle: bool = False,
|
include_background_rectangle: bool = False,
|
||||||
element_config: dict = dict(),
|
|
||||||
element_alignment_corner: Vect3 = DOWN,
|
element_alignment_corner: Vect3 = DOWN,
|
||||||
**kwargs
|
**kwargs
|
||||||
):
|
):
|
||||||
|
|
@ -89,9 +88,9 @@ class Matrix(VMobject):
|
||||||
Matrix can either include numbers, tex_strings,
|
Matrix can either include numbers, tex_strings,
|
||||||
or mobjects
|
or mobjects
|
||||||
"""
|
"""
|
||||||
super().__init__(**kwargs)
|
super().__init__()
|
||||||
|
|
||||||
mob_matrix = self.matrix_to_mob_matrix(matrix, **element_config)
|
mob_matrix = self.matrix_to_mob_matrix(matrix, **kwargs)
|
||||||
self.mob_matrix = mob_matrix
|
self.mob_matrix = mob_matrix
|
||||||
|
|
||||||
self.organize_mob_matrix(mob_matrix, v_buff, h_buff, element_alignment_corner)
|
self.organize_mob_matrix(mob_matrix, v_buff, h_buff, element_alignment_corner)
|
||||||
|
|
|
||||||
|
|
@ -528,7 +528,6 @@ class Mobject(object):
|
||||||
|
|
||||||
# Copying and serialization
|
# Copying and serialization
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def stash_mobject_pointers(func: Callable):
|
def stash_mobject_pointers(func: Callable):
|
||||||
@wraps(func)
|
@wraps(func)
|
||||||
def wrapper(self, *args, **kwargs):
|
def wrapper(self, *args, **kwargs):
|
||||||
|
|
@ -1735,7 +1734,6 @@ class Mobject(object):
|
||||||
|
|
||||||
# Operations touching shader uniforms
|
# Operations touching shader uniforms
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def affects_shader_info_id(func: Callable):
|
def affects_shader_info_id(func: Callable):
|
||||||
@wraps(func)
|
@wraps(func)
|
||||||
def wrapper(self):
|
def wrapper(self):
|
||||||
|
|
|
||||||
|
|
@ -904,7 +904,7 @@ class VMobject(Mobject):
|
||||||
if self.has_fill():
|
if self.has_fill():
|
||||||
tri1 = mobject1.get_triangulation()
|
tri1 = mobject1.get_triangulation()
|
||||||
tri2 = mobject2.get_triangulation()
|
tri2 = mobject2.get_triangulation()
|
||||||
if len(tri1) != len(tri1) or not np.all(tri1 == tri2):
|
if len(tri1) != len(tri2) or not (tri1 == tri2).all():
|
||||||
self.refresh_triangulation()
|
self.refresh_triangulation()
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
@ -1019,7 +1019,6 @@ class VMobject(Mobject):
|
||||||
self.needs_new_triangulation = False
|
self.needs_new_triangulation = False
|
||||||
return tri_indices
|
return tri_indices
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def triggers_refreshed_triangulation(func: Callable):
|
def triggers_refreshed_triangulation(func: Callable):
|
||||||
@wraps(func)
|
@wraps(func)
|
||||||
def wrapper(self, *args, **kwargs):
|
def wrapper(self, *args, **kwargs):
|
||||||
|
|
@ -1126,9 +1125,11 @@ class VMobject(Mobject):
|
||||||
stroke_shader_wrappers,
|
stroke_shader_wrappers,
|
||||||
]
|
]
|
||||||
for sw, sw_list in zip(self.shader_wrapper_list, sw_lists):
|
for sw, sw_list in zip(self.shader_wrapper_list, sw_lists):
|
||||||
|
if not sw_list:
|
||||||
|
continue
|
||||||
sw.read_in(*sw_list)
|
sw.read_in(*sw_list)
|
||||||
sw.depth_test = self.depth_test
|
sw.depth_test = any(sw.depth_test for sw in sw_list)
|
||||||
sw.uniforms = self.uniforms
|
sw.uniforms.update(sw_list[0].uniforms)
|
||||||
return list(filter(lambda sw: len(sw.vert_data) > 0, self.shader_wrapper_list))
|
return list(filter(lambda sw: len(sw.vert_data) > 0, self.shader_wrapper_list))
|
||||||
|
|
||||||
def get_stroke_shader_data(self) -> np.ndarray:
|
def get_stroke_shader_data(self) -> np.ndarray:
|
||||||
|
|
|
||||||
|
|
@ -24,9 +24,12 @@ CLOSED_THRESHOLD = 0.001
|
||||||
def bezier(
|
def bezier(
|
||||||
points: Sequence[Scalable]
|
points: Sequence[Scalable]
|
||||||
) -> Callable[[float], Scalable]:
|
) -> Callable[[float], Scalable]:
|
||||||
|
if len(points) == 0:
|
||||||
|
raise Exception("bezier cannot be calld on an empty list")
|
||||||
|
|
||||||
n = len(points) - 1
|
n = len(points) - 1
|
||||||
|
|
||||||
def result(t: Scalable) -> Scalable:
|
def result(t: float) -> Scalable:
|
||||||
return sum(
|
return sum(
|
||||||
((1 - t)**(n - k)) * (t**k) * choose(n, k) * point
|
((1 - t)**(n - k)) * (t**k) * choose(n, k) * point
|
||||||
for k, point in enumerate(points)
|
for k, point in enumerate(points)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue