[1]:
from manim import *
from manim_geometry import *
config.media_embed = True
config.media_width = "100%"
_RV = "-v WARNING -qm --progress_bar None --disable_caching"
_RI = "-v WARNING -s --progress_bar None --disable_caching"
Manim Community v0.18.0
PentagonΒΆ
I used this video as a reference:
[3]:
FRAME_HEIGHT = config.frame_height
FRAME_WIDTH = config.frame_width
class Pentagon(Scene):
def fade_out(self, *mobs, **kwargs):
self.play(
*map(FadeOut, mobs),
**kwargs
)
def construct(self):
geos = Geos(self, dots_style={"radius": 0.08})
frame_y_radius = FRAME_HEIGHT/2
frame_x_radius = FRAME_WIDTH/2
geos.create_geos({
"lY": geos.line(DOWN*frame_y_radius, UP*frame_y_radius),
"lX": geos.line(LEFT*frame_x_radius, RIGHT*frame_x_radius),
"cO": geos.circle(ORIGIN, 3.5, line_kwargs={"color": RED}),
"dR": geos.dot_from_method(lambda n: n("cO").get_right()),
"dQ": geos.dot_from_method(lambda n: n("cO").get_left()),
"dA": geos.dot_from_method(lambda n: n("cO").get_top()),
"bR": geos.common_chord_partial("dR", "cO"),
"dM": geos.intersection_lines("bR,lX"),
"xMR": geos.distance("dM,dA"),
"aM": geos.arc3p("dQ,dM,dA", radius="xMR", overshot_ang=0, other_angle=True),
"dS": geos.nearest_icl("aM,lX,dQ"),
"xSA": geos.distance("dS,dA"),
"oAS": geos.angle2dots("dA,dS"),
"aA": geos.arc("dA", "xSA", "oAS", -30*DEGREES),
"dB": geos.intersection_circles("aA,cO", close_to="dQ"),
"lEND": geos.segment("dA,dB"),
},
set_all_labels=True,
label_buff=0.05,
)
self.add(geos.lX, geos.lY)
ac = lambda c: {
"all_styles": {"color": c},
"color": c
}
geos.auto_animation("cO")
geos.auto_animation("bR", **ac(BLUE))
geos.show_dot_and_label("dM")
self.fade_out(geos.bR)
geos.auto_animation("aM", show_dot=False, reverse=True, **ac(BLUE))
geos.show_dot_and_label("dS")
geos.auto_animation("aA", show_dot=False)
geos.show_dot_and_label("dB")
geos.auto_animation("lEND", show_dots=False)
self.fade_out(
geos.dM, geos.dS, geos._M, geos._S,
geos.dB, geos._B, geos.aA, geos.aM
)
rotate_line = geos.lEND
main_circle = geos.cO
pentagon = RegularPolygon(
5,
radius=geos.cO.radius,
color=YELLOW,
stroke_width=2
)
pentagon.shift(
-pentagon.get_center_of_mass()
)
arcs = VGroup()
for _ in range(5):
tmp_circle = ICircle(rotate_line.get_length()).move_to(rotate_line.get_end())
arc = tmp_circle.common_chord_group_partial(main_circle, only_arc=True)
arc.reverse_points()
arc.set_stroke(width=3)
arcs.add(arc)
self.play(
Rotate(rotate_line, -arc.angle, about_point=rotate_line.get_end()),
Create(arc),
)
rotate_line.reverse_points()
self.play(FadeOut(rotate_line))
self.play(Create(pentagon))
self.wait()
%manim $_RV Pentagon
[ ]: