Example #1
0
    def __init__(self, mode="plain", **kwargs):
        digest_config(self, kwargs)
        self.mode = mode
        self.parts_named = False
        try:
            svg_file = os.path.join(
                PI_CREATURE_DIR, "%s_%s.svg" % (self.file_name_prefix, mode))
            SVGMobject.__init__(self, file_name=svg_file, **kwargs)
        except Exception:
            warnings.warn("No %s design with mode %s" %
                          (self.file_name_prefix, mode))
            svg_file = os.path.join(
                "media",
                "svg_images",
                "omega_creature",
                "OmegaCreature_plain.svg",
            )
            SVGMobject.__init__(self,
                                mode="plain",
                                file_name=svg_file,
                                **kwargs)

        if self.flip_at_start:
            self.flip()
        if self.start_corner is not None:
            self.to_corner(self.start_corner)
Example #2
0
    def __init__(self, **kwargs):
        SVGMobject.__init__(self, **kwargs)
        self.set_height(self.height)
        self.set_stroke(color=WHITE, width=0)
        self.set_fill(self.color, opacity=1)

        from manimlib.for_3b1b_videos.pi_creature import Randolph
        randy = Randolph(mode="happy")
        randy.set_height(0.6 * self.get_height())
        randy.stretch(0.8, 0)
        randy.look(RIGHT)
        randy.move_to(self)
        randy.shift(0.07 * self.height * (RIGHT + UP))
        self.randy = self.pi_creature = randy
        self.add_to_back(randy)

        orientation_line = Line(self.get_left(), self.get_right())
        orientation_line.set_stroke(width=0)
        self.add(orientation_line)
        self.orientation_line = orientation_line

        for light, color in zip(self.get_lights(), self.light_colors):
            light.set_fill(color, 1)
            light.is_subpath = False

        self.add_treds_to_tires()
Example #3
0
    def __init__(self, text, **config):
        self.full2short(config)
        digest_config(self, config)
        self.lsh = self.size if self.lsh == -1 else self.lsh
        text_without_tabs = text
        if text.find('\t') != -1:
            text_without_tabs = text.replace('\t', ' ' * self.tab_width)
        self.text = text_without_tabs
        file_name = self.text2svg()
        self.remove_last_M(file_name)
        self.remove_empty_path(file_name)
        SVGMobject.__init__(self, file_name, **config)
        self.text = text
        self.apply_space_chars()

        if self.t2c:
            self.set_color_by_t2c()
        if self.gradient:
            self.set_color_by_gradient(*self.gradient)
        if self.t2g:
            self.set_color_by_t2g()

        # anti-aliasing
        if self.height is None:
            self.scale(TEXT_MOB_SCALE_FACTOR * self.font_size)
Example #4
0
    def __init__(self, text, **kwargs):
        self.full2short(kwargs)
        digest_config(self, kwargs)
        if self.size:
            warnings.warn(
                "self.size has been deprecated and will "
                "be removed in future.", DeprecationWarning)
            self.font_size = self.size
        if self.lsh == -1:
            self.lsh = self.font_size + self.font_size * DEFAULT_LINE_SPACING_SCALE
        else:
            self.lsh = self.font_size + self.font_size * self.lsh
        text_without_tabs = text
        if text.find('\t') != -1:
            text_without_tabs = text.replace('\t', ' ' * self.tab_width)
        self.text = text_without_tabs
        file_name = self.text2svg()
        PangoUtils.remove_last_M(file_name)
        self.remove_empty_path(file_name)
        SVGMobject.__init__(self, file_name, **kwargs)
        self.text = text
        if self.disable_ligatures:
            self.apply_space_chars()
        if self.t2c:
            self.set_color_by_t2c()
        if self.gradient:
            self.set_color_by_gradient(*self.gradient)
        if self.t2g:
            self.set_color_by_t2g()

        # anti-aliasing
        if self.height is None:
            self.scale(TEXT_MOB_SCALE_FACTOR)
Example #5
0
    def __init__(self, mode="plain", **kwargs):
        digest_config(self, kwargs)
        self.mode = mode
        self.parts_named = False
        try:
            svg_file = os.path.join(get_directories()["pi_creature_images"],
                                    f"{mode}.svg")
        except Exception:
            logging.log(
                logging.WARNING,
                f"No {self.file_name_prefix} design with mode {mode}",
            )
            svg_file = os.path.join(
                get_directories()["pi_creature_images"],
                "plain.svg",
            )
        SVGMobject.__init__(self, file_name=svg_file, **kwargs)

        if self.flip_at_start:
            self.flip()
        if self.start_corner is not None:
            self.to_corner(self.start_corner)

        # Shouldn't need this, remove?
        self.mouth.insert_n_curves(10)
        self.mouth.set_stroke(BLACK, 1)
Example #6
0
 def __init__(
     self,
     mode="plain",
     creature_name="tau",
     creature_action="ur",
     height=3,
     **kwargs
 ):  #mode: look to the upper left;look to the top right corner;look in the lower left corner;look to the lower right corner
     self.height = height
     digest_config(self, kwargs)
     self.mode = mode
     self.parts_named = False
     try:
         svg_file = os.path.join(
             MY_CREATURE_DIR, "%s_%s_%s.svg" %
             (self.file_name_prefix, creature_name, creature_action))
         SVGMobject.__init__(self, file_name=svg_file, **kwargs)
     except Exception:
         warnings.warn("No %s design with mode %s" %
                       (self.file_name_prefix, mode))
         svg_file = os.path.join(
             MY_CREATURE_DIR,
             "mycreature_tau_plain.svg",
         )
         SVGMobject.__init__(self,
                             mode="plain",
                             file_name=svg_file,
                             **kwargs)
Example #7
0
 def __init__(self, pi_creature, **kwargs):
     SVGMobject.__init__(self, **kwargs)
     self.set_stroke(WHITE, width=0)
     self.set_fill(GREY, 1)
     self.set_width(self.glasses_width_to_eyes_width *
                    pi_creature.eyes.get_width())
     self.move_to(pi_creature.eyes, UP)
Example #8
0
    def __init__(self, text, **config):
        self.text = text
        self.full2short(config)
        digest_config(self, config)
        self.lsh = self.size if self.lsh == -1 else self.lsh

        file_name = self.text2svg()
        self.remove_last_M(file_name)
        SVGMobject.__init__(self, file_name, **config)

        nppc = self.n_points_per_cubic_curve
        for each in self:
            if len(each.points) == 0:
                continue
            points = each.points
            last = points[0]
            each.clear_points()
            for index, point in enumerate(points):
                each.append_points([point])
                if index != len(points) - 1 and (
                        index + 1) % nppc == 0 and any(
                            point != points[index + 1]):
                    each.add_line_to(last)
                    last = points[index + 1]
            each.add_line_to(last)

        if self.t2c:
            self.set_color_by_t2c()
        if self.gradient:
            self.set_color_by_gradient(*self.gradient)
        if self.t2g:
            self.set_color_by_t2g()

        # anti-aliasing
        self.scale(TEXT_MOB_SCALE_FACTOR)
Example #9
0
    def __init__(self, mode="plain", **kwargs):
        digest_config(self, kwargs)
        self.mode = mode
        self.parts_named = False
        try:
            svg_file = os.path.join(
                PI_CREATURE_DIR, "%s_%s.svg" % (self.file_name_prefix, mode))
            SVGMobject.__init__(self, file_name=svg_file, **kwargs)
        except Exception:
            warnings.warn("No %s design with mode %s" %
                          (self.file_name_prefix, mode))
            # TODO, this needs to change to a different, better directory
            svg_file = os.path.join(
                FILE_DIR,
                "PiCreatures_plain.svg",
            )
            SVGMobject.__init__(self,
                                mode="plain",
                                file_name=svg_file,
                                **kwargs)

        if self.flip_at_start:
            self.flip()
        if self.start_corner is not None:
            self.to_corner(self.start_corner)
Example #10
0
 def __init__(self, pi_creature, **kwargs):
     SVGMobject.__init__(self, **kwargs)
     self.set_stroke(WHITE, width=0)
     self.set_fill(GREY, 1)
     self.set_width(
         self.glasses_width_to_eyes_width * pi_creature.eyes.get_width()
     )
     self.move_to(pi_creature.eyes, UP)
Example #11
0
 def __init__(self, **kwargs):
     SVGMobject.__init__(self, **kwargs)
     circle = Circle(
         stroke_width=3,
         stroke_color=GREEN,
         fill_opacity=1,
         fill_color=BLUE_C,
     )
     circle.replace(self)
     self.add_to_back(circle)
Example #12
0
 def __init__(self, **kwargs):
     SVGMobject.__init__(self, **kwargs)
     circle = Circle(
         stroke_width=3,
         stroke_color=GREEN,
         fill_opacity=1,
         fill_color=BLUE_C,
     )
     circle.replace(self)
     self.add_to_back(circle)
Example #13
0
 def __init__(self, **kwargs):
     if not hasattr(self, "args"):
         self.args = serialize_args([])
     if not hasattr(self, "config"):
         self.config = serialize_config({
             **kwargs,
         })
     SVGMobject.__init__(self, **kwargs)
     self.set_width(self.width)
     self.center()
Example #14
0
 def __init__(self, **kwargs):
     if not hasattr(self, "args"):
         self.args = serialize_args([])
     if not hasattr(self, "config"):
         self.config = serialize_config({
             **kwargs,
         })
     SVGMobject.__init__(self, **kwargs)
     self[0].set_fill(self.fill_color, self.fill_opacity)
     self[1].set_fill(self.inner_color, 1)
Example #15
0
 def __init__(self, tex_string, **kwargs):
     digest_config(self, kwargs)
     assert (isinstance(tex_string, str))
     self.tex_string = tex_string
     file_name = tex_to_svg_file(self.get_modified_expression(tex_string),
                                 self.template_tex_file_body)
     SVGMobject.__init__(self, file_name=file_name, **kwargs)
     if self.height is None:
         self.scale(TEX_MOB_SCALE_FACTOR)
     if self.organize_left_to_right:
         self.organize_submobjects_left_to_right()
Example #16
0
 def __init__(self, pi_creature=None, **kwargs):
     digest_config(self, kwargs)
     SVGMobject.__init__(self, file_name=self.file_name, **kwargs)
     self.stretch(self.y_stretch_factor, 1)
     self.set_height(self.height)
     self.set_stroke(width=0)
     self.set_fill(color=self.color)
     if pi_creature is not None:
         eyes = pi_creature.eyes
         self.set_height(3 * eyes.get_height())
         self.move_to(eyes, DOWN)
         self.shift(DOWN * eyes.get_height() / 4)
Example #17
0
 def __init__(self, **kwargs):
     if not hasattr(self, "args"):
         self.args = serialize_args([])
     if not hasattr(self, "config"):
         self.config = serialize_config({
             **kwargs,
         })
     SVGMobject.__init__(self, **kwargs)
     self.center()
     self.set_width(self.width)
     self.set_stroke(color=WHITE, width=0)
     self.set_fill(color=WHITE, opacity=1)
Example #18
0
 def __init__(self, pi_creature=None, **kwargs):
     digest_config(self, kwargs)
     SVGMobject.__init__(self, file_name=self.file_name, **kwargs)
     self.stretch(self.y_stretch_factor, 1)
     self.set_height(self.height)
     self.set_stroke(width=0)
     self.set_fill(color=self.color)
     if pi_creature is not None:
         eyes = pi_creature.eyes
         self.set_height(3 * eyes.get_height())
         self.move_to(eyes, DOWN)
         self.shift(DOWN * eyes.get_height() / 4)
Example #19
0
    def __init__(self, **kwargs):
        SVGMobject.__init__(self, **kwargs)
        self.set_height(self.height)
        if self.pi_creature is not None:
            self.next_to(self.pi_creature.eyes, UP, buff=0)

        self.frills = VGroup(*self[:self.NUM_FRILLS])
        self.cone = self[self.NUM_FRILLS]
        self.dots = VGroup(*self[self.NUM_FRILLS + 1:])

        self.frills.set_color_by_gradient(*self.frills_colors)
        self.cone.set_color(self.cone_color)
        self.dots.set_color_by_gradient(*self.dots_colors)
Example #20
0
    def __init__(self, **kwargs):
        SVGMobject.__init__(self, **kwargs)
        self.set_height(self.height)
        if self.pi_creature is not None:
            self.next_to(self.pi_creature.eyes, UP, buff=0)

        self.frills = VGroup(*self[:self.NUM_FRILLS])
        self.cone = self[self.NUM_FRILLS]
        self.dots = VGroup(*self[self.NUM_FRILLS + 1:])

        self.frills.set_color_by_gradient(*self.frills_colors)
        self.cone.set_color(self.cone_color)
        self.dots.set_color_by_gradient(*self.dots_colors)
Example #21
0
 def __init__(self, pi_creature, **kwargs):
     if not hasattr(self, "args"):
         self.args = serialize_args([pi_creature])
     if not hasattr(self, "config"):
         self.config = serialize_config({
             **kwargs,
         })
     SVGMobject.__init__(self, **kwargs)
     self.set_stroke(WHITE, width=0)
     self.set_fill(GREY, 1)
     self.set_width(self.glasses_width_to_eyes_width *
                    pi_creature.eyes.get_width())
     self.move_to(pi_creature.eyes, UP)
Example #22
0
 def __init__(self, tex_string, **kwargs):
     digest_config(self, kwargs)
     assert(isinstance(tex_string, str))
     self.tex_string = tex_string
     file_name = tex_to_svg_file(
         self.get_modified_expression(tex_string),
         self.template_tex_file_body
     )
     SVGMobject.__init__(self, file_name=file_name, **kwargs)
     if self.height is None:
         self.scale(TEX_MOB_SCALE_FACTOR)
     if self.organize_left_to_right:
         self.organize_submobjects_left_to_right()
Example #23
0
    def __init__(self, **kwargs):
        SVGMobject.__init__(self, **kwargs)
        self.set_stroke(WHITE, width=0)
        colors = [BLUE_E, "#008445", GREEN_B]
        index_lists = [(10, 11, 12, 13, 14, 21, 22, 23, 24, 27, 28, 29, 30),
                       (0, 1, 2, 3, 4, 15, 16, 17, 26),
                       (5, 6, 7, 8, 9, 18, 19, 20, 25)]
        for color, index_list in zip(colors, index_lists):
            for i in index_list:
                self.submobjects[i].set_fill(color, opacity=1)

        self.set_height(self.height)
        self.center()
Example #24
0
 def __init__(self, **kwargs):
     digest_config(self, kwargs, locals())
     if self.file_name is None:
         raise Exception("Must invoke Bubble subclass")
     SVGMobject.__init__(self, self.file_name, **kwargs)
     self.center()
     self.stretch_to_fit_height(self.height)
     self.stretch_to_fit_width(self.width)
     if self.direction[0] > 0:
         self.flip()
     self.direction_was_specified = ("direction" in kwargs)
     self.content = Mobject()
     self.refresh_triangulation()
Example #25
0
    def __init__(self, **kwargs):
        SVGMobject.__init__(self, **kwargs)
        self.set_stroke(WHITE, width=0)
        colors = [BLUE_E, "#008445", GREEN_B]
        index_lists = [
            (10, 11, 12, 13, 14, 21, 22, 23, 24, 27, 28, 29, 30),
            (0, 1, 2, 3, 4, 15, 16, 17, 26),
            (5, 6, 7, 8, 9, 18, 19, 20, 25)
        ]
        for color, index_list in zip(colors, index_lists):
            for i in index_list:
                self.submobjects[i].set_fill(color, opacity=1)

        self.set_height(self.height)
        self.center()
Example #26
0
 def __init__(self, **kwargs):
     digest_config(self, kwargs, locals())
     if self.file_name is None:
         raise Exception("Must invoke Bubble subclass")
     try:
         SVGMobject.__init__(self, **kwargs)
     except IOError as err:
         self.file_name = os.path.join(FILE_DIR, self.file_name)
         SVGMobject.__init__(self, **kwargs)
     self.center()
     self.stretch_to_fit_height(self.height)
     self.stretch_to_fit_width(self.width)
     if self.direction[0] > 0:
         Mobject.flip(self)
     self.direction_was_specified = ("direction" in kwargs)
     self.content = Mobject()
Example #27
0
 def __init__(self, **kwargs):
     digest_config(self, kwargs, locals())
     if self.file_name is None:
         raise Exception("Must invoke Bubble subclass")
     try:
         SVGMobject.__init__(self, **kwargs)
     except IOError as err:
         self.file_name = os.path.join(FILE_DIR, self.file_name)
         SVGMobject.__init__(self, **kwargs)
     self.center()
     self.stretch_to_fit_height(self.height)
     self.stretch_to_fit_width(self.width)
     if self.direction[0] > 0:
         self.flip()
     self.direction_was_specified = ("direction" in kwargs)
     self.content = Mobject()
Example #28
0
    def __init__(self, suit_name, **kwargs):
        digest_config(self, kwargs)
        suits_to_colors = {
            "hearts": self.red,
            "diamonds": self.red,
            "spades": self.black,
            "clubs": self.black,
        }
        if suit_name not in suits_to_colors:
            raise Exception("Invalid suit name")
        SVGMobject.__init__(self, file_name=suit_name, **kwargs)

        color = suits_to_colors[suit_name]
        self.set_stroke(width=0)
        self.set_fill(color, 1)
        self.set_height(self.height)
Example #29
0
 def __init__(self, **kwargs):
     if not hasattr(self, "args"):
         self.args = serialize_args([])
     if not hasattr(self, "config"):
         self.config = serialize_config({
             **kwargs,
         })
     SVGMobject.__init__(self, **kwargs)
     circle = Circle(
         stroke_width=3,
         stroke_color=GREEN,
         fill_opacity=1,
         fill_color=BLUE_C,
     )
     circle.replace(self)
     self.add_to_back(circle)
Example #30
0
    def __init__(self, suit_name, **kwargs):
        digest_config(self, kwargs)
        suits_to_colors = {
            "hearts": self.red,
            "diamonds": self.red,
            "spades": self.black,
            "clubs": self.black,
        }
        if suit_name not in suits_to_colors:
            raise Exception("Invalid suit name")
        SVGMobject.__init__(self, file_name=suit_name, **kwargs)

        color = suits_to_colors[suit_name]
        self.set_stroke(width=0)
        self.set_fill(color, 1)
        self.set_height(self.height)
Example #31
0
    def __init__(self, text, **config):
        self.full2short(config)
        digest_config(self, config)
        self.original_text = text
        text_without_tabs = text
        if text.find('\t') != -1:
            text_without_tabs = text.replace('\t', ' ' * self.tab_width)
        self.text = text_without_tabs
        if self.line_spacing == -1:
            self.line_spacing = self.size + self.size * 0.3
        else:
            self.line_spacing = self.size + self.size * self.line_spacing
        file_name = self.text2svg()
        self.remove_last_M(file_name)
        SVGMobject.__init__(self, file_name, **config)
        self.text = text
        self.submobjects = [*self.gen_chars()]
        self.chars = VGroup(*self.submobjects)
        self.text = text_without_tabs.replace(" ", "").replace("\n", "")
        nppc = self.n_points_per_cubic_curve
        for each in self:
            if len(each.points) == 0:
                continue
            points = each.points
            last = points[0]
            each.clear_points()
            for index, point in enumerate(points):
                each.append_points([point])
                if index != len(points) - 1 and (
                        index + 1) % nppc == 0 and any(
                            point != points[index + 1]):
                    each.add_line_to(last)
                    last = points[index + 1]
            each.add_line_to(last)

        if self.t2c:
            self.set_color_by_t2c()
        if self.gradient:
            self.set_color_by_gradient(*self.gradient)
        if self.t2g:
            self.set_color_by_t2g()

        # anti-aliasing
        if self.height is None and self.width is None:
            self.scale(TEXT_MOB_SCALE_FACTOR)
Example #32
0
    def __init__(self, text, **config):
        self.text = text
        self.full2short(config)
        digest_config(self, config)
        self.lsh = self.size if self.lsh == -1 else self.lsh

        file_name = self.text2svg()
        SVGMobject.__init__(self, file_name, **config)

        if self.t2c:
            self.set_color_by_t2c()
        if self.gradient:
            self.set_color_by_gradient(*self.gradient)
        if self.t2g:
            self.set_color_by_t2g()

        # anti-aliasing
        self.scale(0.1)
Example #33
0
 def __init__(self, pi_creature=None, **kwargs):
     if not hasattr(self, "args"):
         self.args = serialize_args([])
     if not hasattr(self, "config"):
         self.config = serialize_config({
             'pi_creature': pi_creature,
             **kwargs,
         })
     digest_config(self, kwargs)
     SVGMobject.__init__(self, file_name=self.file_name, **kwargs)
     self.stretch(self.y_stretch_factor, 1)
     self.set_height(self.height)
     self.set_stroke(width=0)
     self.set_fill(color=self.color)
     if pi_creature is not None:
         eyes = pi_creature.eyes
         self.set_height(3 * eyes.get_height())
         self.move_to(eyes, DOWN)
         self.shift(DOWN * eyes.get_height() / 4)
Example #34
0
    def __init__(self, **kwargs):
        if not hasattr(self, "args"):
            self.args = serialize_args([])
        if not hasattr(self, "config"):
            self.config = serialize_config({
                **kwargs,
            })
        SVGMobject.__init__(self, **kwargs)
        self.set_height(self.height)
        if self.pi_creature is not None:
            self.next_to(self.pi_creature.eyes, UP, buff=0)

        self.frills = VGroup(*self[:self.NUM_FRILLS])
        self.cone = self[self.NUM_FRILLS]
        self.dots = VGroup(*self[self.NUM_FRILLS + 1:])

        self.frills.set_color_by_gradient(*self.frills_colors)
        self.cone.set_color(self.cone_color)
        self.dots.set_color_by_gradient(*self.dots_colors)
Example #35
0
    def __init__(self, **kwargs):
        if not hasattr(self, "args"):
            self.args = serialize_args([])
        if not hasattr(self, "config"):
            self.config = serialize_config({
                **kwargs,
            })
        SVGMobject.__init__(self, **kwargs)

        path = self.submobjects[0]
        subpaths = path.get_subpaths()
        path.clear_points()
        for indices in [(0, 1), (2, 3), (4, 6, 7), (5, ), (8, )]:
            part = VMobject()
            for index in indices:
                part.append_points(subpaths[index])
            path.add(part)

        self.set_height(self.height)
        self.set_stroke(color=WHITE, width=0)
        self.set_fill(self.color, opacity=1)

        from manimlib.for_3b1b_videos.pi_creature import Randolph
        randy = Randolph(mode="happy")
        randy.set_height(0.6 * self.get_height())
        randy.stretch(0.8, 0)
        randy.look(RIGHT)
        randy.move_to(self)
        randy.shift(0.07 * self.height * (RIGHT + UP))
        self.randy = self.pi_creature = randy
        self.add_to_back(randy)

        orientation_line = Line(self.get_left(), self.get_right())
        orientation_line.set_stroke(width=0)
        self.add(orientation_line)
        self.orientation_line = orientation_line

        for light, color in zip(self.get_lights(), self.light_colors):
            light.set_fill(color, 1)
            light.is_subpath = False

        self.add_treds_to_tires()
    def __init__(self, mode="plain", **kwargs):
        digest_config(self, kwargs)
        self.mode = mode
        self.parts_named = False
        try:
            svg_file = os.path.join(
                PI_CREATURE_DIR, "%s_%s.svg" % (self.file_name_prefix, mode))
            SVGMobject.__init__(self, file_name=svg_file, **kwargs)
        except Exception:
            warnings.warn("No %s design with mode %s" %
                          (self.file_name_prefix, mode))
            #svg_file = os.path.join("/Users/muhammad/Documents/Shared/ArduinoUno copy1.1.svg",)
            SVGMobject.__init__(self,
                                mode="plain",
                                file_name=svg_file,
                                **kwargs)

        if self.flip_at_start:
            self.flip()
        if self.start_corner is not None:
            self.to_corner(self.start_corner)
Example #37
0
    def __init__(self, text, **config):
        self.full2short(config)
        digest_config(self, config)
        if self.size:
            warnings.warn(
                "self.size has been deprecated and will "
                "be removed in future.",
                DeprecationWarning
            )
            self.font_size = self.size
        if self.lsh == -1:
            self.lsh = self.font_size + self.font_size * DEFAULT_LINE_SPACING_SCALE
        else:
            self.lsh = self.font_size + self.font_size * self.lsh
        text_without_tabs = text
        if text.find('\t') != -1:
            text_without_tabs = text.replace('\t', ' ' * self.tab_width)
        self.text = text_without_tabs
        file_name = self.text2svg()
        PangoUtils.remove_last_M(file_name)
        self.remove_empty_path(file_name)
        SVGMobject.__init__(self, file_name, **config)
        self.text = text
        if self.disable_ligatures:
            self.apply_space_chars()
        if self.t2c:
            self.set_color_by_t2c()
        if self.gradient:
            self.set_color_by_gradient(*self.gradient)
        if self.t2g:
            self.set_color_by_t2g()

        # anti-aliasing
        if self.height is None:
            self.scale(TEXT_MOB_SCALE_FACTOR)

        # Just a temporary hack to get better triangulation
        # See pr #1552 for details
        for i in self.submobjects:
            i.insert_n_curves(len(i.get_points()))
Example #38
0
    def __init__(self, suit_name, **kwargs):
        if not hasattr(self, "args"):
            self.args = serialize_args([suit_name])
        if not hasattr(self, "config"):
            self.config = serialize_config({
                **kwargs,
            })
        digest_config(self, kwargs)
        suits_to_colors = {
            "hearts": self.red,
            "diamonds": self.red,
            "spades": self.black,
            "clubs": self.black,
        }
        if suit_name not in suits_to_colors:
            raise Exception("Invalid suit name")
        SVGMobject.__init__(self, file_name=suit_name, **kwargs)

        color = suits_to_colors[suit_name]
        self.set_stroke(width=0)
        self.set_fill(color, 1)
        self.set_height(self.height)
Example #39
0
    def __init__(self, mode="plain", **kwargs):
        digest_config(self, kwargs)
        self.mode = mode
        self.parts_named = False
        try:
            svg_file = os.path.join(
                PI_CREATURE_DIR,
                "%s_%s.svg" % (self.file_name_prefix, mode)
            )
            SVGMobject.__init__(self, file_name=svg_file, **kwargs)
        except Exception:
            warnings.warn("No %s design with mode %s" %
                          (self.file_name_prefix, mode))
            svg_file = os.path.join(
                FILE_DIR,
                "PiCreatures_plain.svg",
            )
            SVGMobject.__init__(self, mode="plain", file_name=svg_file, **kwargs)

        if self.flip_at_start:
            self.flip()
        if self.start_corner is not None:
            self.to_corner(self.start_corner)
Example #40
0
    def __init__(self, **kwargs):
        SVGMobject.__init__(self, **kwargs)

        path = self.submobjects[0]
        subpaths = path.get_subpaths()
        path.clear_points()
        for indices in [(0, 1), (2, 3), (4, 6, 7), (5,), (8,)]:
            part = VMobject()
            for index in indices:
                part.append_points(subpaths[index])
            path.add(part)

        self.set_height(self.height)
        self.set_stroke(color=WHITE, width=0)
        self.set_fill(self.color, opacity=1)

        from manimlib.for_3b1b_videos.pi_creature import Randolph
        randy = Randolph(mode="happy")
        randy.set_height(0.6 * self.get_height())
        randy.stretch(0.8, 0)
        randy.look(RIGHT)
        randy.move_to(self)
        randy.shift(0.07 * self.height * (RIGHT + UP))
        self.randy = self.pi_creature = randy
        self.add_to_back(randy)

        orientation_line = Line(self.get_left(), self.get_right())
        orientation_line.set_stroke(width=0)
        self.add(orientation_line)
        self.orientation_line = orientation_line

        for light, color in zip(self.get_lights(), self.light_colors):
            light.set_fill(color, 1)
            light.is_subpath = False

        self.add_treds_to_tires()
Example #41
0
 def __init__(self, **kwargs):
     SVGMobject.__init__(self, **kwargs)
     self.set_width(self.width)
     self.center()
Example #42
0
 def __init__(self, **kwargs):
     SVGMobject.__init__(self, **kwargs)
     self.center()
     self.set_width(self.width)
     self.set_stroke(color=WHITE, width=0)
     self.set_fill(color=WHITE, opacity=1)
Example #43
0
 def __init__(self, **kwargs):
     SVGMobject.__init__(self, **kwargs)
     self[0].set_fill(self.fill_color, self.fill_opacity)
     self[1].set_fill(self.inner_color, 1)