Пример #1
0
 def apply_space_chars(self):
     char_index = 0
     while char_index < self.text.__len__() - 1:
         char_index += 1
         if self.text[char_index] == " " or self.text[char_index] == "\t" or self.text[char_index] == "\n":
             space = Dot(fill_opacity=0, stroke_opacity=0)
             space.move_to(self.submobjects[char_index - 1].get_center())
             self.submobjects.insert(char_index, space)
Пример #2
0
 def apply_space_chars(self):
     submobs = self.submobjects.copy()
     for char_index in range(len(self.text)):
         if self.text[char_index] in [" ", "\t", "\n"]:
             space = Dot(radius=0, fill_opacity=0, stroke_opacity=0)
             space.move_to(submobs[max(char_index - 1, 0)].get_center())
             submobs.insert(char_index, space)
     self.set_submobjects(submobs)
Пример #3
0
 def apply_space_chars(self):
     for char_index in range(self.text.__len__()):
         if self.text[char_index] == " " or self.text[char_index] == "\t" or self.text[char_index] == "\n":
             space = Dot(redius=0, fill_opacity=0, stroke_opacity=0)
             if char_index == 0:
                 space.move_to(self.submobjects[char_index].get_center())
             else:
                 space.move_to(self.submobjects[char_index - 1].get_center())
             self.submobjects.insert(char_index, space)
Пример #4
0
    def __init__(self, mobject_or_point, **kwargs):
        digest_config(self, kwargs)
        big_dot = Dot(
            radius=FRAME_X_RADIUS + FRAME_Y_RADIUS,
            stroke_width=0,
            fill_color=self.color,
            fill_opacity=0,
        )
        little_dot = Dot(radius=0)
        little_dot.set_fill(self.color, opacity=self.opacity)
        little_dot.move_to(mobject_or_point)

        Transform.__init__(self, big_dot, little_dot, **kwargs)
Пример #5
0
 def apply_space_chars(self):
     indexes = self.find_indexes(' ') + self.find_indexes('\n')
     indexes = sorted(indexes, key=lambda i: i[0])
     if len(self.text) == len(indexes):
         space = Dot(fill_opacity=0, stroke_opacity=0)
         self.submobjects = [space.copy() for _ in range(len(indexes))]
         return
     for start, _ in indexes:
         space = Dot(fill_opacity=0, stroke_opacity=0)
         if start == 0:
             space.move_to(self.submobjects[0].get_center())
         else:
             space.move_to(self.submobjects[start - 1].get_center())
         self.submobjects.insert(start, space)
Пример #6
0
    def generate_mobject(self):
        super().generate_mobject()

        # Remove empty paths
        submobjects = list(filter(lambda submob: submob.has_points(), self))

        # Apply space characters
        if self.apply_space_chars:
            content_str = self.parser.remove_tags(self.text)
            if self.is_markup:
                content_str = saxutils.unescape(content_str)
            for char_index, char in enumerate(content_str):
                if not re.match(r"\s", char):
                    continue
                space = Dot(radius=0, fill_opacity=0, stroke_opacity=0)
                space.move_to(submobjects[max(char_index - 1, 0)].get_center())
                submobjects.insert(char_index, space)
        self.set_submobjects(submobjects)
Пример #7
0
 def gen_chars(self):
     chars = VGroup()
     submobjects_char_index = 0
     for char_index in range(self.text.__len__()):
         if self.text[char_index] == " " or self.text[
                 char_index] == "\t" or self.text[char_index] == "\n":
             space = Dot(redius=0, fill_opacity=0, stroke_opacity=0)
             if char_index == 0:
                 space.move_to(
                     self.submobjects[submobjects_char_index].get_center())
             else:
                 space.move_to(self.submobjects[submobjects_char_index -
                                                1].get_center())
             chars.add(space)
         else:
             chars.add(self.submobjects[submobjects_char_index])
             submobjects_char_index += 1
     return chars