Advertisement
Guest User

Untitled

a guest
Feb 14th, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.19 KB | None | 0 0
  1. from manimlib.imports import *
  2.  
  3. class WhatCanDo(Scene):
  4.     def construct(self):
  5.         text = VGroup(
  6.                 TextMobject("What animations"),
  7.                 TextMobject("can we do?")
  8.             )
  9.         text.arrange(DOWN)\
  10.                 .scale(2.5)\
  11.                 .set_fill(opacity=0)
  12.  
  13.         screen = Rectangle(
  14.                             width=FRAME_WIDTH,
  15.                             height=FRAME_HEIGHT
  16.                 )
  17.         for position,t in zip([LEFT,RIGHT],text):
  18.             t_c = t.copy()
  19.             t.next_to(screen,position,buff=0)
  20.             t.set_y(t_c.get_y())
  21.  
  22.         def show_text(text_):
  23.             t1,t2 = text_
  24.             t1.set_x(0)
  25.             t2.set_x(0)
  26.             text_.set_fill(opacity=1)
  27.             return text_
  28.  
  29.         def disappear_text(text_):
  30.             for position,t in zip([RIGHT,LEFT],text_):
  31.                 t_c = t.copy()
  32.                 t.next_to(screen,position,buff=0)
  33.                 t.set_y(t_c.get_y())
  34.                 t.set_fill(opacity=0)
  35.             return text_
  36.  
  37.         self.play(ApplyFunction(show_text,text))
  38.         self.wait()
  39.         self.play(ApplyFunction(disappear_text,text))
  40.         self.wait()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement