Skip to content

Instantly share code, notes, and snippets.

@uwezi
Last active March 19, 2023 12:33
Show Gist options
  • Save uwezi/8a59b8e7c7b34a117be3626bd336e080 to your computer and use it in GitHub Desktop.
Save uwezi/8a59b8e7c7b34a117be3626bd336e080 to your computer and use it in GitHub Desktop.
[Fold line to square] How to make a square from a single line. #manim #fold #animate
# https://discord.com/channels/581738731934056449/1021439985615913051/1021439985615913051
from manim import *
class square_from_line(Scene):
def construct(self):
line1 = Line(start=ORIGIN, end=1*RIGHT)
line2 = line1.copy().shift(1*RIGHT)
line3 = line2.copy().shift(1*RIGHT)
line4 = line3.copy().shift(1*RIGHT)
all = VGroup(line1,line2,line3,line4)
grp2 = VGroup(line2,line3,line4)
grp3 = VGroup(line3,line4)
self.play(Write(all))
self.wait(2)
self.play(Rotate(grp2, angle=90*DEGREES, about_point=1*RIGHT))
self.play(Rotate(grp3, angle=90*DEGREES, about_point=1*RIGHT+1*UP))
self.play(Rotate(line4, angle=90*DEGREES, about_point=1*UP))
self.wait(2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment