Exemple #1
0
    def __init__(self, label, radius=None, **kwargs) -> None:
        if isinstance(label, str):
            from manim import MathTex

            rendered_label = MathTex(label, color=BLACK)
        else:
            rendered_label = label

        if radius is None:
            radius = (0.1 + max(rendered_label.get_width(),
                                rendered_label.get_height()) / 2)
        Dot.__init__(self, radius=radius, **kwargs)
        rendered_label.move_to(self.get_center())
        self.add(rendered_label)
Exemple #2
0
    def __init__(
        self,
        label: str | SingleStringMathTex | Text | Tex,
        radius: float | None = None,
        **kwargs,
    ) -> None:
        if isinstance(label, str):
            from manim import MathTex

            rendered_label = MathTex(label, color=BLACK)
        else:
            rendered_label = label

        if radius is None:
            radius = 0.1 + max(rendered_label.width, rendered_label.height) / 2
        super().__init__(radius=radius, **kwargs)
        rendered_label.move_to(self.get_center())
        self.add(rendered_label)
    def __init__(self,
                 label,
                 width=None,
                 height=None,
                 width_buff=0.1,
                 height_buff=0.1,
                 color=WHITE,
                 fill_color=WHITE,
                 fill_opacity=1.0,
                 corner_radius=0.1,
                 tip_direction=None,
                 tip_height=0.3,
                 tip_width=0.3,
                 **kwargs) -> None:
        if isinstance(label, str):
            from manim import MathTex

            rendered_label = MathTex(label, color=BLACK)
        else:
            rendered_label = label

        if width is None:
            width = (2 * width_buff + rendered_label.get_width())
        if height is None:
            height = (2 * height_buff + rendered_label.get_height())

        RoundedRectangle.__init__(self,
                                  width=width,
                                  height=height,
                                  color=color,
                                  fill_color=fill_color,
                                  fill_opacity=fill_opacity,
                                  corner_radius=corner_radius,
                                  **kwargs)
        rendered_label.move_to(self.get_center())
        self.add(rendered_label)

        if (tip_direction is not None):
            self.set_tip(tip_direction=tip_direction,
                         tip_height=tip_height,
                         tip_width=tip_width,
                         color=color,
                         fill_opacity=fill_opacity,
                         **kwargs)