Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

New feature: set_row_colors for matrix mobject

Philipp Imhofa22880dad922
diff --git a/manimlib/mobject/matrix.py b/manimlib/mobject/matrix.py
index 8fa266a13..6af9db6f9 100644
--- a/manimlib/mobject/matrix.py
+++ b/manimlib/mobject/matrix.py
@@ -127,6 +127,18 @@ class Matrix(VMobject):
column.set_color(color)
return self
+ def get_rows(self):
+ return VGroup(*[
+ VGroup(*self.mob_matrix[i, :])
+ for i in range(self.mob_matrix.shape[1])
+ ])
+
+ def set_row_colors(self, *colors):
+ rows = self.get_rows()
+ for color, row in zip(colors, rows):
+ row.set_color(color)
+ return self
+
def add_background_to_entries(self):
for mob in self.get_entries():
mob.add_background_rectangle()