Exemple #1
0
 def to_corner(self, vect=None, **kwargs):
     if vect is not None:
         SVGMobject.to_corner(self, vect, **kwargs)
     else:
         self.scale(self.corner_scale_factor)
         self.to_corner(DOWN + LEFT, **kwargs)
     return self
 def to_corner(self, vect=None, **kwargs):
     if vect is not None:
         SVGMobject.to_corner(self, vect, **kwargs)
     else:
         self.scale(self.corner_scale_factor)
         self.to_corner(DOWN + LEFT, **kwargs)
     return self
Exemple #3
0
 def generate_points(self):
     self.drunk = SVGMobject(file_name="drunk",
                             color=self.color,
                             height=self.height)
     self.point = VectorizedPoint(self.drunk.get_bottom())
     self.add(self.drunk, self.point)
     self.rotate(angle_between(RIGHT, self.direction))
Exemple #4
0
    def __init__(self, **kwargs):
        SVGMobject.__init__(self, **kwargs)
        self.scale_to_fit_height(self.height)
        self.set_stroke(color = WHITE, width = 0)
        self.set_fill(self.color, opacity = 1)

        from for_3b1b_videos.pi_creature import Randolph
        randy = Randolph(mode = "happy")
        randy.scale_to_fit_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()
Exemple #5
0
 def __init__(self, pi_creature, **kwargs):
     SVGMobject.__init__(self, **kwargs)
     self.set_stroke(WHITE, width=0)
     self.set_fill(GREY, 1)
     self.scale_to_fit_width(self.glasses_width_to_eyes_width *
                             pi_creature.eyes.get_width())
     self.move_to(pi_creature.eyes, UP)
Exemple #6
0
    def __init__(self, **kwargs):
        SVGMobject.__init__(self, **kwargs)
        self.scale_to_fit_height(self.height)
        self.set_stroke(color=WHITE, width=0)
        self.set_fill(self.color, opacity=1)

        from for_3b1b_videos.pi_creature import Randolph
        randy = Randolph(mode="happy")
        randy.scale_to_fit_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()
Exemple #7
0
 def __init__(self, pi_creature, **kwargs):
     SVGMobject.__init__(self, **kwargs)
     self.set_stroke(WHITE, width=0)
     self.set_fill(GREY, 1)
     self.scale_to_fit_width(
         self.glasses_width_to_eyes_width * pi_creature.eyes.get_width()
     )
     self.move_to(pi_creature.eyes, UP)
Exemple #8
0
 def init_colors(self):
     SVGMobject.init_colors(self)
     if not self.parts_named:
         self.name_parts()
     self.mouth.set_fill(BLACK, opacity=1)
     self.body.set_fill(self.color, opacity=1)
     self.pupils.set_fill(BLACK, opacity=1)
     self.eyes.set_fill(WHITE, opacity=1)
     return self
 def init_colors(self):
     SVGMobject.init_colors(self)
     if not self.parts_named:
         self.name_parts()
     self.mouth.set_fill(BLACK, opacity=1)
     self.body.set_fill(self.color, opacity=1)
     self.pupils.set_fill(BLACK, opacity=1)
     self.eyes.set_fill(WHITE, opacity=1)
     return self
Exemple #10
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)
Exemple #11
0
 def init_colors(self):
     SVGMobject.init_colors(self)
     if not self.parts_named:
         self.name_parts()
     self.mouth.set_fill(BLACK, opacity=1)
     self.body.set_fill(self.color, opacity=1)
     self.pupils.set_fill(BLACK, opacity=1)
     # self.pupils.set_stroke(DARK_GREY, width=1)
     self.add_pupil_light_spot(self.pupils)
     self.eyes.set_fill(WHITE, opacity=1)
     return self
Exemple #12
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.scale_to_fit_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.scale_to_fit_height(3*eyes.get_height())
         self.move_to(eyes, DOWN)
         self.shift(DOWN*eyes.get_height()/4)
Exemple #13
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.scale_to_fit_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.scale_to_fit_height(3 * eyes.get_height())
         self.move_to(eyes, DOWN)
         self.shift(DOWN * eyes.get_height() / 4)
Exemple #14
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.scale_to_fit_height(self.height)
        self.center()
Exemple #15
0
    def __init__(self, **kwargs):
        SVGMobject.__init__(self, **kwargs)
        self.scale_to_fit_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)
Exemple #16
0
    def __init__(self, **kwargs):
        SVGMobject.__init__(self, **kwargs)
        self.scale_to_fit_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)
Exemple #17
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.scale_to_fit_height(self.height)
        self.center()
Exemple #18
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.scale_to_fit_height(self.height)
Exemple #19
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()
Exemple #20
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.scale_to_fit_height(self.height)
Exemple #21
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()
Exemple #22
0
class Drunk(VMobject):
    CONFIG = {
        "direction": RIGHT,
        "color": YELLOW_E,
        "height": 1,
    }

    def generate_points(self):
        self.drunk = SVGMobject(file_name="drunk",
                                color=self.color,
                                height=self.height)
        self.point = VectorizedPoint(self.drunk.get_bottom())
        self.add(self.drunk, self.point)
        self.rotate(angle_between(RIGHT, self.direction))

    def get_position(self):
        return self.point.get_center()

    def step_on(self, position):
        self.shift(position - self.get_position())
        return self

    def turn_around(self, **kwargs):
        axis = rotate_vector(self.direction, np.pi / 2)
        self.rotate(np.pi, axis=axis, **kwargs)
        self.change_direction()
        return self

    def get_direction(self):
        return self.direction

    def change_direction(self):
        self.direction = -self.direction
Exemple #23
0
    def __init__(self, mode="plain", **kwargs):
        digest_config(self, kwargs)
        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:
            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, 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)
    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:
            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, 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)
Exemple #25
0
class House(VMobject):
    CONFIG = {
        "color": DARK_GREY,
        "height": 3,
    }

    def generate_points(self):
        self.house = SVGMobject(file_name="house",
                                color=self.color,
                                height=self.height)
        self.point = VectorizedPoint(self.house.get_bottom())
        self.add(self.house, self.point)

    def get_position(self):
        return self.point.get_center()

    def place_on(self, position):
        self.shift(position - self.get_position())
        return self
Exemple #26
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)
 def align_data(self, mobject):
     # This ensures that after a transform into a different mode,
     # the pi creatures mode will be updated appropriately
     SVGMobject.align_data(self, mobject)
     if isinstance(mobject, PiCreature):
         self.mode = mobject.get_mode()
Exemple #28
0
 def __init__(self, **kwargs):
     SVGMobject.__init__(self, **kwargs)
     self.center()
     self.scale_to_fit_width(self.width)
     self.set_stroke(color = WHITE, width = 0)
     self.set_fill(color = WHITE, opacity = 1)
Exemple #29
0
 def __init__(self, **kwargs):
     SVGMobject.__init__(self, **kwargs)
     self.scale_to_fit_width(self.width)
     self.center()
Exemple #30
0
 def copy(self):
     copy_mobject = SVGMobject.copy(self)
     copy_mobject.name_parts()
     return copy_mobject
Exemple #31
0
 def __init__(self, **kwargs):
     SVGMobject.__init__(self, **kwargs)
     self.center()
     self.scale_to_fit_width(self.width)
     self.set_stroke(color=WHITE, width=0)
     self.set_fill(color=WHITE, opacity=1)
Exemple #32
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)
Exemple #33
0
    def get_face_card_design(self, value, symbol):
        from 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()
        pi_mode = {
            "J": "plain",
            "Q": "thinking",
            "K": "hooray"
        }[value]
        pi_creature = PiCreature(
            mode=pi_mode,
            color=pi_color,
        )
        pi_creature.scale_to_fit_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)
Exemple #34
0
 def generate_points(self):
     self.house = SVGMobject(file_name="house",
                             color=self.color,
                             height=self.height)
     self.point = VectorizedPoint(self.house.get_bottom())
     self.add(self.house, self.point)
Exemple #35
0
    def get_face_card_design(self, value, symbol):
        from 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()
        pi_mode = {
            "J" : "plain",
            "Q" : "thinking",
            "K" : "hooray"
        }[value]
        pi_creature = PiCreature(
            mode = pi_mode,
            color = pi_color,
        )
        pi_creature.scale_to_fit_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)
Exemple #36
0
 def __init__(self, **kwargs):
     SVGMobject.__init__(self, **kwargs)
     self.scale_to_fit_width(self.width)
     self.center()
 def copy(self):
     copy_mobject = SVGMobject.copy(self)
     copy_mobject.name_parts()
     return copy_mobject
Exemple #38
0
 def align_data(self, mobject):
     # This ensures that after a transform into a different mode,
     # the pi creatures mode will be updated appropriately
     SVGMobject.align_data(self, mobject)
     if isinstance(mobject, PiCreature):
         self.mode = mobject.get_mode()