Skip to content

Instantly share code, notes, and snippets.

@uwezi
Last active March 19, 2023 12:38
Show Gist options
  • Save uwezi/9f05690e34d06b79e4d52f4f0aa216f1 to your computer and use it in GitHub Desktop.
Save uwezi/9f05690e34d06b79e4d52f4f0aa216f1 to your computer and use it in GitHub Desktop.
[leaving a trace in Manim] How to leave a trace of objects by making copies. #manim #copy #trace #shift
# https://discord.com/channels/581738731934056449/1020700254061989939/1020700254061989939
from manim import *
class tracesquare(MovingCameraScene):
def construct(self):
grid = NumberPlane()
self.add(grid)
s = Square(side_length=2, color=RED, fill_opacity=0.2)
self.add(grid, s)
for dir in [UP * 2,LEFT * 2,DOWN * 5,RIGHT * 5,LEFT * 6]:
a = s.copy()
s.set_color(color=GREEN)
s.set_fill(color=GREEN)
s.set_opacity(0.4)
self.play(a.animate.shift(dir))
s = a
self.wait(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment