본문 바로가기

Programming

(165)
[015]Text: font size t1 = Text("Hello 0.1", font='굴림', stroke_width=1, size=0.1) t2 = Text("Hello 0.2", font='굴림', stroke_width=1, size=0.2) t3 = Text("Hello 0.3", font='굴림', stroke_width=1, size=0.3) t4 = Text("Hello 0.4", font='굴림', stroke_width=1, size=0.4) t5 = Text("Hello 0.5", font='굴림', stroke_width=1, size=0.5) t6 = Text("Hello 0.7 ", font='굴림', stroke_width=1, size=0.7) t7 = Text("Hello 1", font='굴림', strok..
[014]Text/TextMobject/TexMobject Text, TextMobject str = Text("페르마의 마지막 정리", font='바탕') text = TextMobject("방정식 $x^n + y^n = z^n$를 만족하는 $(x,y,z)$값이 존재하지 않는다") tex = TexMobject("x^n + y^n = z^n") group = VGroup(str,text, tex) group.arrange(DOWN) self.add(group) self.wait() Text: t2c t1 = Text("Hello, this is one sentence", font='굴림', size=0.5, stroke_width=1, t2c={'Hello': YELLOW, 'one': RED} ) t2 = Text("Google", font='Arial', ..
[013]Text: Transform eq = TexMobject("a^2", "+", "b^2", "=", "c^2") eq.save_state() self.add(eq) self.play( eq[0].become,TexMobject("3^2").move_to(eq[0]), eq[2].become,TexMobject("4^2").move_to(eq[2]), eq[4].become,TexMobject("5^2").move_to(eq[4]), run_time=2, ) self.wait() eq.restore() self.add() self.play( Transform(eq[0], TexMobject("3^2").move_to(eq[0])), Transform(eq[2], TexMobject("4^2").move_to(eq[2])), Trans..
[012]TextMobject.set_color/set_color_by_map Text Color: tex_to_color_map t1 = TexMobject( "P(A|B) = {P(A)P(B|A) \\over P(B)}", tex_to_color_map={ "A": YELLOW, "B": BLUE, }, ) self.add(t1) self.wait() Text Color: set_color_by_tex eq = TexMobject("x", "=", "L", "\\theta") eq.set_color_by_tex("\\theta", BLUE) self.add(eq) self.wait() Text Color: set_color_by_tex_to_color_map(1) all_words = VGroup( TextMobject("You have a\\\\", "hypothesis"),..
[011]Text/TextMobject Text Class str = ["사과","배", "대추", "감", "먹고 싶다"] text = VGroup(*[Text(s, font='J신영복 Regular') for s in str]) text.arrange(DOWN) self.add(text) self.wait() TextMobject Class (1) tex = TexMobject("a^2","+", "b^2","=","c^2") self.add(tex) self.wait() self.play( tex[0].set_color, RED, tex[2].set_color, RED, tex[4].become, TexMobject("d^2").move_to(tex[4]), # Transform(tex[4], TexMobject("d^2").move_t..
[010]save_state/restore class RestoreTest(Scene): def construct(self): dot = Dot() dot.save_state() self.add(dot) self.play(dot.shift, 2 * UP) self.wait() self.play(dot.shift, 5 * DOWN) self.wait() self.play(dot.restore) self.wait()
[008]align_to/arrange/arrange_in_grid align_to class AlignToTest(Scene): def construct(self): dir_str = [ 'UP', 'DOWN', 'LEFT', 'RIGHT'] dir_list = [ UP, DOWN, LEFT, RIGHT] rect = Rectangle(width=1, height=0.4) rect_tgt = Rectangle(width=3, height=2).shift(RIGHT * 3, UP * 2) self.add(rect, rect_tgt) for str, dir in zip(dir_str, dir_list): new_rect = rect.copy() obj = self.get_text_rect(str, new_rect) self.play(obj.align_to, rect_tgt..
[007]mob.get_left/mob.get_right rect = Rectangle(width=1.5, height=1) you_label = TextMobject("you") you_label.next_to(rect, RIGHT, MED_LARGE_BUFF) arrow = Arrow(you_label.get_left(), rect.get_right() + 0.5 * LEFT, buff=0.1) self.add(rect,you_label, arrow) self.wait()
[006]Example: Coordinate Methods Example 1 class CoordinateEx1(Scene): def construct(self): #1. create objects title = self.get_title() body = self.get_body() subtitle = self.get_subtitle() #2. locate objects title.move_to(ORIGIN).to_edge(UP, buff=1) body.next_to(title, DOWN, buff=1) subtitle.to_edge(DOWN, buff=0.5) #3. animate objects self.play(FadeIn(title), run_time=2) self.play(FadeIn(body), run_time=2) self.play(FadeIn(sub..
[005]mob.shift class ShiftTest(Scene): def construct(self): self.move_around_with_one_object() def move_around_with_one_object(self): dot = Dot() directions = [RIGHT, UP, LEFT, LEFT, DOWN, DOWN, RIGHT, RIGHT] self.add(dot) for d in directions: self.play(dot.shift, d) self.wait() self.remove(dot) class ShiftTest(Scene): def construct(self): self.make_latttice() def make_latttice(self): dot = Dot() directions = ..