示例#1
0
 def __init__(self, **kwargs):
     VGroup.__init__(self, **kwargs)
     for i in range(self.width):
         for j in range(self.height):
             pi = PiCreature().scale(0.3)
             pi.move_to(i * DOWN + j * RIGHT)
             self.add(pi)
示例#2
0
 def __init__(self, **kwargs):
     VGroup.__init__(self, **kwargs)
     for i in range(self.width):
         for j in range(self.height):
             pi = PiCreature().scale(0.3)
             pi.move_to(i * DOWN + j * RIGHT)
             self.add(pi)
示例#3
0
 def generate_points(self):
     random.seed(self.random_seed)
     modes = get_all_pi_creature_modes()
     seed = PiCreature(mode=self.start_mode)
     seed.set_height(self.height)
     seed.to_edge(DOWN)
     creatures = [seed]
     self.add(VGroup(seed))
     for x in range(self.order):
         new_creatures = []
         for creature in creatures:
             for eye, vect in zip(creature.eyes, [LEFT, RIGHT]):
                 new_creature = PiCreature(
                     mode=random.choice(modes)
                 )
                 new_creature.set_height(
                     self.scale_val * eye.get_height()
                 )
                 new_creature.next_to(
                     eye, vect,
                     buff=0,
                     aligned_edge=DOWN
                 )
                 new_creatures.append(new_creature)
             creature.look_at(random.choice(new_creatures))
         self.add_to_back(VGroup(*new_creatures))
         creatures = new_creatures
示例#4
0
    def get_face_card_design(self, value, symbol):
        from manimlib.for_3b1b_videos.pi_creature import PiCreature
        sub_rect = Rectangle(
            stroke_color=BLACK,
            fill_opacity=0,
            height=0.9 * self.get_height(),
            width=0.6 * self.get_width(),
        )
        sub_rect.move_to(self)

        # pi_color = average_color(symbol.get_color(), GREY)
        pi_color = symbol.get_color()
        if Color(pi_color) == Color(BLACK):
            pi_color = GREY_D
        pi_mode = {"J": "plain", "Q": "thinking", "K": "hooray"}[value]
        pi_creature = PiCreature(
            mode=pi_mode,
            color=pi_color,
        )
        pi_creature.set_width(0.8 * sub_rect.get_width())
        if value in ["Q", "K"]:
            prefix = "king" if value == "K" else "queen"
            crown = SVGMobject(file_name=prefix + "_crown")
            crown.set_stroke(width=0)
            crown.set_fill(YELLOW, 1)
            crown.stretch_to_fit_width(0.5 * sub_rect.get_width())
            crown.stretch_to_fit_height(0.17 * sub_rect.get_height())
            crown.move_to(pi_creature.eyes.get_center(), DOWN)
            pi_creature.add_to_back(crown)
            to_top_buff = 0
        else:
            to_top_buff = SMALL_BUFF * sub_rect.get_height()
        pi_creature.next_to(sub_rect.get_top(), DOWN, to_top_buff)
        # pi_creature.shift(0.05*sub_rect.get_width()*RIGHT)

        pi_copy = pi_creature.copy()
        pi_copy.rotate(np.pi, about_point=sub_rect.get_center())

        return VGroup(sub_rect, pi_creature, pi_copy)
示例#5
0
 def create_pi_creature(self):
     pi_creature = PiCreature(**self.default_pi_creature_kwargs)
     pi_creature.to_corner(self.default_pi_creature_start_corner)
     return pi_creature
示例#6
0
 def create_pi_creature(self):
     pi_creature = PiCreature(**self.default_pi_creature_kwargs)
     pi_creature.to_corner(self.default_pi_creature_start_corner)
     return pi_creature
示例#7
0
 def generate_points(self):
     random.seed(self.random_seed)
     modes = get_all_pi_creature_modes()
     seed = PiCreature(mode=self.start_mode)
     seed.set_height(self.height)
     seed.to_edge(DOWN)
     creatures = [seed]
     self.add(VGroup(seed))
     for x in range(self.order):
         new_creatures = []
         for creature in creatures:
             for eye, vect in zip(creature.eyes, [LEFT, RIGHT]):
                 new_creature = PiCreature(
                     mode=random.choice(modes)
                 )
                 new_creature.set_height(
                     self.scale_val * eye.get_height()
                 )
                 new_creature.next_to(
                     eye, vect,
                     buff=0,
                     aligned_edge=DOWN
                 )
                 new_creatures.append(new_creature)
             creature.look_at(random.choice(new_creatures))
         self.add_to_back(VGroup(*new_creatures))
         creatures = new_creatures