Created
November 8, 2020 09:36
-
-
Save lovemyliwu/5b050db61f5fc97f6474b11e71164f14 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from manimlib.imports import * | |
class Main(Scene): | |
def construct(self): | |
dot = Dot() | |
line = Line() | |
arrow = Arrow() | |
circle = Circle() | |
annulus = Annulus() | |
triangle = Triangle() | |
rectangle = Rectangle() | |
self.play(Transform(dot, line)) | |
self.play(Transform(dot, arrow)) | |
self.play(Transform(dot, circle)) | |
self.play(Transform(dot, annulus)) | |
self.play(Transform(dot, triangle)) | |
self.play(Transform(dot, rectangle)) | |
self.play(FadeOut(dot)) | |
self.clear() | |
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) | |
self.play(FadeIn(rectangle), FadeIn(flag), FadeIn(counter)) | |
# 矩形更新 | |
def update_width(ob): | |
print(f'current {ob.width}') | |
ob.width += 1 | |
ob.shift(UP*0.1) | |
ob.set_width(ob.width, stretch=True) | |
rectangle.add_updater(update_width) | |
# 数字更新 | |
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)) | |
self.play(Write(Line(start=LEFT_SIDE, end=RIGHT_SIDE).move_to(BOTTOM))) | |
self.wait() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment