Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Reduce complexity of AngleExample (#1451)

Jan-Hendrik Müller61456469ca71
diff --git a/manim/mobject/geometry.py b/manim/mobject/geometry.py
index 3a1a319d6..365f0e80d 100644
--- a/manim/mobject/geometry.py
+++ b/manim/mobject/geometry.py
@@ -2312,17 +2312,12 @@ class Angle(Arc, Elbow):
Angle(line1, line2, radius=0.5, quadrant=(-1,1), stroke_width=8, dot=True, dot_color=YELLOW, dot_radius=0.04, other_angle=True),
Angle(line1, line2, radius=0.7, quadrant=(-1,-1), color=RED, dot=True, dot_color=GREEN, dot_radius=0.08),
]
- line_list = VGroup( *[VGroup() for k in range(4)] )
- for k in range(4):
- linea = line1.copy()
- lineb = line2.copy()
- line_list[k].add( linea )
- line_list[k].add( lineb )
- line_list[k].add( rightarcangles[k] )
- line_list.arrange_in_grid(buff=1.5)
- self.add(
- line_list
- )
+ plots = VGroup()
+ for angle in rightarcangles:
+ plot=VGroup(line1.copy(),line2.copy(), angle)
+ plots.add(plot)
+ plots.arrange(buff=1.5)
+ self.add(plots)
.. manim:: AngleExample
:save_last_frame:
@@ -2341,17 +2336,13 @@ class Angle(Arc, Elbow):
Angle(line1, line2, radius=0.5, quadrant=(-1,1), stroke_width=8),
Angle(line1, line2, radius=0.7, quadrant=(-1,-1), color=RED, other_angle=True),
]
- line_list = VGroup( *[VGroup() for k in range(8)] )
- for k in range(8):
- linea = line1.copy()
- lineb = line2.copy()
- line_list[k].add( linea )
- line_list[k].add( lineb )
- line_list[k].add( angles[k] )
- line_list.arrange_in_grid(n_rows=2, n_cols=4, buff=1.5)
- self.add(
- line_list
- )
+ plots = VGroup()
+ for angle in angles:
+ plot=VGroup(line1.copy(),line2.copy(), angle)
+ plots.add(VGroup(plot,SurroundingRectangle(plot, buff=0.3)))
+ plots.arrange_in_grid(rows=2,buff=1)
+ self.add(plots)
+
.. manim:: FilledAngle
:save_last_frame:
@@ -2502,18 +2493,12 @@ class RightAngle(Angle):
RightAngle(line1, line2, length=0.5, quadrant=(-1,1), stroke_width=8),
RightAngle(line1, line2, length=0.7, quadrant=(-1,-1), color=RED),
]
- line_list = VGroup( *[VGroup() for k in range(4)] )
- for k in range(4):
- linea = line1.copy()
- lineb = line2.copy()
- line_list[k].add( linea )
- line_list[k].add( lineb )
- line_list[k].add( rightangles[k] )
- line_list.arrange_in_grid(buff=1.5)
- self.add(
- line_list
- )
-
+ plots = VGroup()
+ for rightangle in rightangles:
+ plot=VGroup(line1.copy(),line2.copy(), rightangle)
+ plots.add(plot)
+ plots.arrange(buff=1.5)
+ self.add(plots)
"""
def __init__(self, line1, line2, length=None, **kwargs):