コード例 #1
0
ファイル: shape_matchers.py プロジェクト: unAlpha/AgManim
 def get_tex(self,
             tex,
             scale=1,
             buff=1,
             invert_dir=False,
             invert_texto=False,
             remove_rot=True,
             **moreargs):
     linea_referencia = Line(self[0][0].get_start(), self[0][-1].get_end())
     texto = TexMobject(tex, **moreargs)
     ancho = texto.get_height() / 2
     if invert_texto:
         inv = PI
     else:
         inv = 0
     if remove_rot:
         texto.scale(scale).move_to(self)
     else:
         texto.rotate(
             linea_referencia.get_angle()).scale(scale).move_to(self)
         texto.rotate(inv)
     if invert_dir:
         inv = -1
     else:
         inv = 1
     texto.shift(self.direccion * (buff + 1) * ancho)
     return texto
コード例 #2
0
ファイル: shape_matchers.py プロジェクト: unAlpha/AgManim
 def add_tex(self, text, scale=1, buff=-1, **moreargs):
     linea_referencia = Line(self[0][0].get_start(), self[0][-1].get_end())
     texto = TexMobject(text, **moreargs)
     ancho = texto.get_height() / 2
     texto.rotate(linea_referencia.get_angle()).scale(scale).move_to(self)
     texto.shift(self.direccion * (buff + 1) * ancho)
     return self.add(texto)
コード例 #3
0
 def add_label(self):
     circle = self.circle
     label = TexMobject(
         "%d" % int(np.round(1. / self.radius)),
         background_stroke_width=0,
     )
     h_factor = circle.get_width() * 0.6 / label.get_width()
     v_factor = circle.get_height() * 0.5 / label.get_height()
     factor = np.min([h_factor, v_factor])
     label.scale(factor)
     label.move_to(self.center)
     self.add(label)
     self.label = label
コード例 #4
0
 def generate_n_choose_k_mobs(self):
     self.coords_to_n_choose_k = {}
     for n, k in self.coords:
         nck_mob = TexMobject(r"{%d \choose %d}" % (n, k))
         scale_factor = min(
             1,
             self.portion_to_fill * self.cell_height / nck_mob.get_height(),
             self.portion_to_fill * self.cell_width / nck_mob.get_width(),
         )
         center = self.coords_to_mobs[n][k].get_center()
         nck_mob.center().scale(scale_factor).shift(center)
         if n not in self.coords_to_n_choose_k:
             self.coords_to_n_choose_k[n] = {}
         self.coords_to_n_choose_k[n][k] = nck_mob
     return self
コード例 #5
0
ファイル: combinatorics.py プロジェクト: coallaoh/manim
 def generate_n_choose_k_mobs(self):
     self.coords_to_n_choose_k = {}
     for n, k in self.coords:
         nck_mob = TexMobject(r"{%d \choose %d}" % (n, k))
         scale_factor = min(
             1,
             self.portion_to_fill * self.cell_height / nck_mob.get_height(),
             self.portion_to_fill * self.cell_width / nck_mob.get_width(),
         )
         center = self.coords_to_mobs[n][k].get_center()
         nck_mob.center().scale(scale_factor).shift(center)
         if n not in self.coords_to_n_choose_k:
             self.coords_to_n_choose_k[n] = {}
         self.coords_to_n_choose_k[n][k] = nck_mob
     return self
コード例 #6
0
    def initialize_texts(self):
        proof_texts = TextMobject("“证明”:", "涂颜色", "+", "换视角")
        proof_texts.arrange_submobjects(RIGHT)
        proof_texts.to_corner(LEFT + UP)

        imagine_3d_text = TextMobject("(想象这是一个三维图案...)")
        imagine_3d_text.to_corner(RIGHT + UP)
        imagine_3d_text.set_color(YELLOW)

        rhombi = VGroup(*[
            RhombusType(rhombus_config={"fill_opacity": 1})
            for RhombusType in (RRhombus, HRhombus, LRhombus)
        ])
        time_texts = VGroup(*[
            TexMobject("\\times", "n^2").scale(1.2).set_color(
                rhombus.get_fill_color()) for rhombus in rhombi
        ])
        rhombi_and_texts = VGroup(*[
            VGroup(rhombus, time_text).arrange_submobjects(RIGHT)
            for rhombus, time_text in zip(rhombi, time_texts)
        ])
        rhombi_and_texts.arrange_submobjects(RIGHT, buff=2)
        rhombi_and_texts.to_edge(UP, buff=1.4)

        equation = TexMobject(
            *["n^2" if k % 2 == 0 else "=" for k in range(5)])
        for text, color in zip(equation[::2], RHOMBI_COLOR_SET):
            text.set_color(color)
        qed = FakeQEDSymbol(jagged_percentage=0.1)
        qed.set_height(equation.get_height())
        conclusions = VGroup(equation, qed)
        conclusions.arrange_submobjects(RIGHT, buff=1)
        conclusions.to_corner(RIGHT + UP)

        self.proof_texts = proof_texts
        self.imagine_3d_text = imagine_3d_text
        self.rhombi = rhombi
        self.time_texts = time_texts
        self.rhombi_and_texts = rhombi_and_texts
        self.conclusions = conclusions