Skip to content

Instantly share code, notes, and snippets.

Created November 8, 2020 09:36
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
from manimlib.imports import *
class Main(Scene):
def construct(self):
dot = Dot()
line = Line()
arrow = Arrow()
circle = Circle()
annulus = Annulus()
triangle = Triangle()
rectangle = Rectangle(), line)), arrow)), circle)), annulus)), triangle)), rectangle))
rectangle = Rectangle(color=RED, width=1, height=1).set_fill(color=RED, opacity=0.5).move_to(LEFT_SIDE)
flag = ImageMobject('media/china.jpeg', height=1).next_to(rectangle)
counter = Integer(1101).next_to(flag), FadeIn(flag), FadeIn(counter))
# 矩形更新
def update_width(ob):
print(f'current {ob.width}')
ob.width += 1
ob.set_width(ob.width, stretch=True)
# 数字更新
counter.add_updater(lambda ob: ob.set_value(rectangle.get_width()))
# 位置更新
flag.add_updater(lambda ob: ob.next_to(rectangle))
counter.add_updater(lambda ob: ob.next_to(flag)), end=RIGHT_SIDE).move_to(BOTTOM)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment