Example #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)
Example #2
0
 def __init__(self, mobject, **kwargs):
     VGroup.__init__(self,
                     Line(UP + LEFT, DOWN + RIGHT),
                     Line(UP + RIGHT, DOWN + LEFT),
                     )
     self.replace(mobject, stretch=True)
     self.set_stroke(self.stroke_color, self.stroke_width)
Example #3
0
 def __init__(self, **kwargs):
     digest_config(self, kwargs)
     videos = [VideoIcon() for x in range(self.num_videos)]
     VGroup.__init__(self, *videos, **kwargs)
     self.arrange()
     self.set_width(FRAME_WIDTH - MED_LARGE_BUFF)
     self.set_color_by_gradient(*self.gradient_colors)
Example #4
0
    def __init__(self, values, **kwargs):
        VGroup.__init__(self, **kwargs)
        if self.max_value is None:
            self.max_value = max(values)

        self.add_axes()
        self.add_bars(values)
        self.center()
Example #5
0
 def __init__(self, **kwargs):
     possible_values = list(map(str, list(range(1, 11)))) + ["J", "Q", "K"]
     possible_suits = ["hearts", "diamonds", "spades", "clubs"]
     VGroup.__init__(self, *[
         PlayingCard(value=value, suit=suit, **kwargs)
         for value in possible_values
         for suit in possible_suits
     ])
Example #6
0
    def __init__(self, stream_lines, **kwargs):
        VGroup.__init__(self, **kwargs)
        self.stream_lines = stream_lines
        for line in stream_lines:
            line.anim = self.line_anim_class(line, **self.line_anim_config)
            line.anim.begin()
            line.time = -self.lag_range * random.random()
            self.add(line.anim.mobject)

        self.add_updater(lambda m, dt: m.update(dt))
Example #7
0
    def __init__(self, *vertices, **kwargs):
        VGroup.__init__(self, **kwargs)
        self.lines, self.dots = VGroup(plot_depth=1), VGroup(plot_depth=1)
        self.poly=Polygon(*vertices, fill_color=self.fill_color,
                          fill_opacity=self.fill_opacity, plot_depth=0).set_stroke(width=0)
        self.add(self.poly, self.lines, self.dots)

        n = len(vertices)
        for i in range(n):
            self.lines.add(Line(vertices[i], vertices[(i+1) % n], color=self.stroke_color,
                                stroke_width=self.stroke_width))
            self.dots.add(Dot(vertices[i], color=self.stroke_color).set_height(self.stroke_width/100))

        for dot in self.dots:
            dot.add_updater(lambda d: d.set_height(self.stroke_width/100))
Example #8
0
    def __init__(self, **kwargs):
        circle = Circle()
        ticks = []
        for x in range(12):
            alpha = x / 12.
            point = complex_to_R3(np.exp(2 * np.pi * alpha * complex(0, 1)))
            length = 0.2 if x % 3 == 0 else 0.1
            ticks.append(Line(point, (1 - length) * point))
        self.hour_hand = Line(ORIGIN, 0.3 * UP)
        self.minute_hand = Line(ORIGIN, 0.6 * UP)
        # for hand in self.hour_hand, self.minute_hand:
        #     #Balance out where the center is
        #     hand.add(VectorizedPoint(-hand.get_end()))

        VGroup.__init__(self, circle, self.hour_hand, self.minute_hand, *ticks)
Example #9
0
 def __init__(self, **kwargs):
     VGroup.__init__(self, **kwargs)
     self.x_axis = self.create_axis(
         self.x_min, self.x_max, self.x_axis_config
     )
     self.y_axis = self.create_axis(
         self.y_min, self.y_max, self.y_axis_config
     )
     self.y_axis.rotate(90 * DEGREES, about_point=ORIGIN)
     # Add as a separate group incase various other
     # mobjects are added to self, as for example in
     # NumberPlane below
     self.axes = VGroup(self.x_axis, self.y_axis)
     self.add(*self.axes)
     self.shift(self.center_point)
Example #10
0
 def __init__(self, func, **kwargs):
     VGroup.__init__(self, **kwargs)
     self.func = func
     self.rgb_gradient_function = get_rgb_gradient_function(
         self.min_magnitude,
         self.max_magnitude,
         self.colors,
         flip_alphas=False)
     x_range = np.arange(self.x_min, self.x_max + self.delta_x,
                         self.delta_x)
     y_range = np.arange(self.y_min, self.y_max + self.delta_y,
                         self.delta_y)
     for x, y in it.product(x_range, y_range):
         point = x * RIGHT + y * UP
         self.add(self.get_vector(point))
     self.set_opacity(self.opacity)
Example #11
0
    def __init__(self, stream_lines, **kwargs):
        if not hasattr(self, "args"):
            self.args = serialize_args([stream_lines])
        if not hasattr(self, "config"):
            self.config = serialize_config({
                **kwargs,
            })
        VGroup.__init__(self, **kwargs)
        self.stream_lines = stream_lines
        for line in stream_lines:
            line.anim = self.line_anim_class(line, **self.line_anim_config)
            line.anim.begin()
            line.time = -self.lag_range * random.random()
            self.add(line.anim.mobject)

        self.add_updater(lambda m, dt: m.update(dt))
Example #12
0
 def __init__(self, x_range=None, y_range=None, **kwargs):
     VGroup.__init__(self, **kwargs)
     self.x_axis = self.create_axis(
         x_range or self.x_range,
         self.x_axis_config,
         self.width,
     )
     self.y_axis = self.create_axis(y_range or self.y_range,
                                    self.y_axis_config, self.height)
     self.y_axis.rotate(90 * DEGREES, about_point=ORIGIN)
     # Add as a separate group in case various other
     # mobjects are added to self, as for example in
     # NumberPlane below
     self.axes = VGroup(self.x_axis, self.y_axis)
     self.add(*self.axes)
     self.center()
 def __init__(self,
              point,
              strs,
              offset=[0, 0, 0],
              height=None,
              color=None,
              mobj=1):
     VGroup.__init__(self)
     if isinstance(mobj, (int, float, bool)):
         if int(mobj) == 1:
             self.add(GeomPoint(point))
         else:
             self.add(GeomMark(point))
     self.add(
         TextMobject(strs,
                     height=height).move_to(point,
                                            offset=offset).set_color(color))
Example #14
0
    def __init__(self, func, **kwargs):
        if not hasattr(self, "args"):
            self.args = serialize_args([func])
        if not hasattr(self, "config"):
            self.config = serialize_config({
                **kwargs,
            })
        VGroup.__init__(self, **kwargs)
        self.func = func
        dt = self.dt

        start_points = self.get_start_points(
            **self.start_points_generator_config)
        for point in start_points:
            points = [point]
            for t in np.arange(0, self.virtual_time, dt):
                last_point = points[-1]
                points.append(last_point + dt * func(last_point))
                if get_norm(last_point) > self.cutoff_norm:
                    break
            line = VMobject()
            step = max(1, int(len(points) / self.n_anchors_per_line))
            line.set_points_smoothly(points[::step])
            self.add(line)

        self.set_stroke(self.stroke_color, self.stroke_width)

        if self.color_by_arc_length:
            len_to_rgb = get_rgb_gradient_function(
                self.min_arc_length,
                self.max_arc_length,
                colors=self.colors,
            )
            for line in self:
                arc_length = line.get_arc_length()
                rgb = len_to_rgb([arc_length])[0]
                color = rgb_to_color(rgb)
                line.set_color(color)
        elif self.color_by_magnitude:
            image_file = get_color_field_image_file(
                lambda p: get_norm(func(p)),
                min_value=self.min_magnitude,
                max_value=self.max_magnitude,
                colors=self.colors,
            )
            self.color_using_background_image(image_file)
Example #15
0
 def __init__(self, *text, **config):
     Container.__init__(self, **config)
     self.lines_list = list(text)
     self.lines = []
     self.lines.append([])
     for line_no in range(self.lines_list.__len__()):
         if "\n" in self.lines_list[line_no]:
             self.lines_list[line_no:line_no + 1] = self.lines_list[line_no].split("\n")
     for line_no in range(self.lines_list.__len__()):
         self.lines[0].append(TextWithFixHeight(self.lines_list[line_no], **config))
     self.char_height = TextWithFixHeight("(", **config).get_height()
     self.lines.append([])
     self.lines[1].extend([self.alignment for _ in range(self.lines_list.__len__())])
     self.lines[0][0].move_to(np.array([0, 0, 0]))
     self.align_lines()
     VGroup.__init__(self, *[self.lines[0][i] for i in range(self.lines[0].__len__())], **config)
     self.move_to(np.array([0, 0, 0]))
Example #16
0
    def __init__(self, texmob, **kwargs):

        self.texmob = texmob
        self.anim_controller = ValueTracker(0.)
        VGroup.__init__(
            self, *[
                self.texmob[i][j] for i in range(len(self.texmob))
                for j in range(len(self.texmob[i]))
            ], **kwargs)
        self.submob_pos = [mob.get_center() for mob in self]
        self.submob_size = [mob.get_height() for mob in self]
        if self.change_opacity:
            self.submob_opacity = [self.init_opacity for mob in self]
        else:
            self.submob_opacity = [1 for mob in self]
        # self.get_new_ratefunc()
        self.activate_anim()
Example #17
0
 def __init__(self, **kwargs):
     VGroup.__init__(self, **kwargs)
     self.id_to_pos = [
         0, 144, 161,
         126, 127, 138, 139, 140, 141, 142, 143,
         108, 109, 120, 121, 122, 123, 124, 125,
         *list(range(90, 108)),
         *list(range(72, 90)),
         54, 55,
         *list(range(20, 35)),
         *list(range(57, 72)),
         36, 37,
         *list(range(2, 17)),
         *list(range(39, 54))
     ]
     self.create_boxes()
     self.mask_array = np.zeros((9, 18))
     self.colors = color_gradient([BLUE_D, YELLOW, RED, RED_D], 110)
Example #18
0
    def __init__(self, mob_or_points, **kwargs):
        VGroup.__init__(self, **kwargs)

        if type(mob_or_points) == list:
            self.shape = Polygon(*mob_or_points, stroke_width=0, plot_depth=-1)
        else:
            self.shape = mob_or_points.set_stroke(width=0)

        self.shape.set_fill(color=self.shadow_color, opacity=self.shadow_opacity * (1 if self.show_basic_shape else 0)).scale(self.scale_factor)
        self.blur_outline = VGroup()
        s = (self.shape.get_height() + self.shape.get_width())/2
        if self.blur_width > 1e-4:
            for i in range(self.layer_num):
                layer_i = self.shape.copy().set_stroke(color=self.shadow_color, width=100 * self.blur_width/self.layer_num, opacity=self.shadow_opacity * (1-self.rate_func(i/self.layer_num))).\
                    set_fill(opacity=0).scale((s + (1 if self.shadow_out else -1) * self.blur_width/self.layer_num * (i+0.5))/ s).set_plot_depth(-2)
                self.blur_outline.add(layer_i)

        self.add(self.shape, self.blur_outline)
Example #19
0
    def __init__(self, mob, **kwargs):

        VGroup.__init__(self, **kwargs)
        if type(self.stroke_colors) == list:
            stroke_colors = color_gradient(self.stroke_colors, self.num)
        else:
            stroke_colors = color_gradient([self.stroke_colors, self.stroke_colors], self.num)
        for i in range(self.num):
            t = i/(self.num-1)
            shift_i = self.rate_func(t) * self.shift_vect
            # scale_i = min(self.scale_range) + self.rate_func(t) * (max(self.scale_range)-min(self.scale_range))
            if self.scale_type == 0:
                scale_i = np.exp(np.log(self.scale_range[0]) + self.rate_func(t) * (np.log(self.scale_range[1])-np.log(self.scale_range[0])))
            else:
                scale_i = self.scale_range[0] + self.rate_func(t) * (self.scale_range[1]-self.scale_range[0])
            theta_i = self.rate_func(t) * self.rotate_angle
            mob_i = mob.copy().shift(shift_i)
            mob_i.scale(scale_i, about_point=mob_i.get_center_of_mass()).rotate(theta_i, about_point=mob_i.get_center_of_mass()).set_stroke(color=stroke_colors[i])
            self.add(mob_i)
Example #20
0
    def __init__(self, *functiongraphs, **kwargs):
        VGroup.__init__(self, **kwargs)
        functionsgraphs = []
        # self.add(exec("FunctionGraph("+functiongraphs[0]+")"))
        [
            exec(
                "functionsgraphs.append(FunctionGraph(" + functiongraph + "))",
                {
                    "functionsgraphs": functionsgraphs,
                    "FunctionGraph": FunctionGraph
                }) for functiongraph in functiongraphs
        ]

        vmobject = VMobject()
        [
            vmobject.append_vectorized_mobject(functionsgraph)
            for functionsgraph in functionsgraphs
        ]
        self.add(vmobject)
    def __init__(self, init_loc=ORIGIN, **kwargs):

        VGroup.__init__(self, **kwargs)
        self.point = Dot(init_loc,
                         color=self.point_color).set_height(self.size)
        self.value_x = DecimalNumber(
            0,
            color=self.coordinates_color,
            num_decimal_places=self.num_decimal_places).scale(
                self.coordinates_scale)
        self.value_y = DecimalNumber(
            0,
            color=self.coordinates_color,
            num_decimal_places=self.num_decimal_places).scale(
                self.coordinates_scale)
        text = TexMobject('(', ',', ')').scale(self.coordinates_scale)
        self.coordinates_text = VGroup(text[0], self.value_x, text[1],
                                       self.value_y, text[2])
        self.coordinates_text.add_updater(self.update_coordinates_text)
        self.add(self.point)
Example #22
0
    def __init__(self, func, **kwargs):
        VGroup.__init__(self, **kwargs)
        self.func = func
        dt = self.dt

        start_points = self.get_start_points(
            **self.start_points_generator_config
        )
        for point in start_points:
            points = [point]
            for t in np.arange(0, self.virtual_time, dt):
                last_point = points[-1]
                points.append(last_point + dt * func(last_point))
                if get_norm(last_point) > self.cutoff_norm:
                    break
            line = VMobject()
            step = max(1, int(len(points) / self.n_anchors_per_line))
            line.set_points_smoothly(points[::step])
            self.add(line)

        self.set_stroke(self.stroke_color, self.stroke_width)

        if self.color_by_arc_length:
            len_to_rgb = get_rgb_gradient_function(
                self.min_arc_length,
                self.max_arc_length,
                colors=self.colors,
            )
            for line in self:
                arc_length = line.get_arc_length()
                rgb = len_to_rgb([arc_length])[0]
                color = rgb_to_color(rgb)
                line.set_color(color)
        elif self.color_by_magnitude:
            image_file = get_color_field_image_file(
                lambda p: get_norm(func(p)),
                min_value=self.min_magnitude,
                max_value=self.max_magnitude,
                colors=self.colors,
            )
            self.color_using_background_image(image_file)
Example #23
0
    def __init__(self, mobject, count=1, posratio=0.5, width=4, length=0.3, color=GOLD, opacity=1, space=0.07, *args, **kwargs):
        VGroup.__init__(self, **kwargs)
        if isinstance(mobject, VGroup):
            numofcurves = len(mobject.submobjects)

            def func(i):
                return mobject.submobjects[i]
        else:
            numofcurves = mobject.get_num_curves()

            def func(i):
                return CurveLine(mobject, i)
        if isinstance(count, int):
            def number(i):
                return count
        elif callable(count):
            def number(i):
                return count(i)+1
        kwargs["dimhash"] = self.dimhash
        [self.add(Hash(func(i), number(i), posratio=posratio, length=length,
                       space=space,  *args, **kwargs)) for i in range(numofcurves)]
Example #24
0
    def __init__(self, **kwargs):
        if not hasattr(self, "args"):
            self.args = serialize_args([])
        if not hasattr(self, "config"):
            self.config = serialize_config({
                **kwargs,
            })
        circle = Circle(color=WHITE)
        ticks = []
        for x in range(12):
            alpha = x / 12.
            point = complex_to_R3(np.exp(2 * np.pi * alpha * complex(0, 1)))
            length = 0.2 if x % 3 == 0 else 0.1
            ticks.append(Line(point, (1 - length) * point))
        self.hour_hand = Line(ORIGIN, 0.3 * UP)
        self.minute_hand = Line(ORIGIN, 0.6 * UP)
        # for hand in self.hour_hand, self.minute_hand:
        #     #Balance out where the center is
        #     hand.add(VectorizedPoint(-hand.get_end()))

        VGroup.__init__(self, circle, self.hour_hand, self.minute_hand, *ticks)
Example #25
0
 def __init__(self, func, **kwargs):
     if not hasattr(self, "args"):
         self.args = serialize_args([func])
     if not hasattr(self, "config"):
         self.config = serialize_config({
             **kwargs,
         })
     VGroup.__init__(self, **kwargs)
     self.func = func
     self.rgb_gradient_function = get_rgb_gradient_function(
         self.min_magnitude,
         self.max_magnitude,
         self.colors,
         flip_alphas=False)
     x_range = np.arange(self.x_min, self.x_max + self.delta_x,
                         self.delta_x)
     y_range = np.arange(self.y_min, self.y_max + self.delta_y,
                         self.delta_y)
     for x, y in it.product(x_range, y_range):
         point = x * RIGHT + y * UP
         self.add(self.get_vector(point))
     self.set_opacity(self.opacity)
    def __init__(self, **kwargs):

        VGroup.__init__(self, **kwargs)
        self.color_list = color_gradient(self.colors, self.layer_num)
        self.add(
            Dot(color=average_color(self.colors[0], WHITE),
                plot_depth=4).set_height(0.015 * self.radius))
        for i in range(self.layer_num):
            # self.add(Arc(radius= self.radius/self.layer_num * (0.5 + i), angle=TAU, color=self.color_list[i],
            #              stroke_width=100 * self.radius/self.layer_num,
            #              stroke_opacity=self.opacity_func(i/self.layer_num), plot_depth=5))
            self.add(
                Arc(radius=self.radius * self.rate_func(
                    (0.5 + i) / self.layer_num),
                    angle=TAU,
                    color=self.color_list[i],
                    stroke_width=101 *
                    (self.rate_func((i + 1) / self.layer_num) -
                     self.rate_func(i / self.layer_num)) * self.radius,
                    stroke_opacity=self.opacity_func(
                        self.rate_func(i / self.layer_num)),
                    plot_depth=5))
Example #27
0
 def __init__(self, **kwargs):
     VGroup.__init__(self, **kwargs)
     x_axis_config = merge_config([
         self.x_axis_config,
         {
             "x_min": self.x_min,
             "x_max": self.x_min
         },
         self.number_line_config,
     ])
     y_axis_config = merge_config([
         self.y_axis_config,
         {
             "x_min": self.y_min,
             "x_max": self.y_min
         },
         self.number_line_config,
     ])
     self.x_axis = NumberLine(**x_axis_config)
     self.y_axis = NumberLine(**y_axis_config)
     self.y_axis.rotate(90 * DEGREES, about_point=ORIGIN)
     self.add(self.x_axis, self.y_axis)
Example #28
0
 def __init__(self, func, **kwargs):
     VGroup.__init__(self, **kwargs)
     self.func = func
     self.rgb_gradient_function = get_rgb_gradient_function(
         self.min_magnitude,
         self.max_magnitude,
         self.colors,
         flip_alphas=False
     )
     x_range = np.arange(
         self.x_min,
         self.x_max + self.delta_x,
         self.delta_x
     )
     y_range = np.arange(
         self.y_min,
         self.y_max + self.delta_y,
         self.delta_y
     )
     for x, y in it.product(x_range, y_range):
         point = x * RIGHT + y * UP
         self.add(self.get_vector(point))
     self.set_opacity(self.opacity)
Example #29
0
    def __init__(self, **kwargs):
        circle = Circle(color=WHITE)
        ticks = []
        for x in range(12):
            alpha = x / 12.
            point = complex_to_R3(
                np.exp(2 * np.pi * alpha * complex(0, 1))
            )
            length = 0.2 if x % 3 == 0 else 0.1
            ticks.append(
                Line(point, (1 - length) * point)
            )
        self.hour_hand = Line(ORIGIN, 0.3 * UP)
        self.minute_hand = Line(ORIGIN, 0.6 * UP)
        # for hand in self.hour_hand, self.minute_hand:
        #     #Balance out where the center is
        #     hand.add(VectorizedPoint(-hand.get_end()))

        VGroup.__init__(
            self, circle,
            self.hour_hand, self.minute_hand,
            *ticks
        )
Example #30
0
 def __init__(self, **kwargs):
     #### EULERTOUR_INIT_START ####
     if not hasattr(self, "args"):
         self.args = serialize_args([])
     if not hasattr(self, "config"):
         self.config = serialize_config({
             **kwargs,
         })
     #### EULERTOUR_INIT_START ####
     VGroup.__init__(self, **kwargs)
     self.x_axis = self.create_axis(
         self.x_min, self.x_max, self.x_axis_config
     )
     self.y_axis = self.create_axis(
         self.y_min, self.y_max, self.y_axis_config
     )
     self.y_axis.rotate(90 * DEGREES, about_point=ORIGIN)
     # Add as a separate group incase various other
     # mobjects are added to self, as for example in
     # NumberPlane below
     self.axes = VGroup(self.x_axis, self.y_axis)
     self.add(*self.axes)
     self.shift(self.center_point)
Example #31
0
    def __init__(self, mob, **kwargs):
        VGroup.__init__(self, **kwargs)
        if self.dashed == True:
            medicion = DashedLine(
                ORIGIN,
                mob.get_length() * RIGHT,
                dashed_segment_length=self.dashed_segment_length).set_color(
                    self.color)
        else:
            medicion = Line(ORIGIN, mob.get_length() * RIGHT)

        medicion.set_stroke(None, self.stroke)

        pre_medicion = Line(ORIGIN,
                            self.lateral * RIGHT).rotate(PI / 2).set_stroke(
                                None, self.stroke)
        pos_medicion = pre_medicion.copy()

        pre_medicion.move_to(medicion.get_start())
        pos_medicion.move_to(medicion.get_end())

        angulo = mob.get_angle()
        matriz_rotacion = rotation_matrix(PI / 2, OUT)
        vector_unitario = mob.get_unit_vector()
        direccion = np.matmul(matriz_rotacion, vector_unitario)
        self.direccion = direccion

        self.add(medicion, pre_medicion, pos_medicion)
        self.rotate(angulo)
        self.move_to(mob)

        if self.invert == True:
            self.shift(-direccion * self.buff)
        else:
            self.shift(direccion * self.buff)
        self.set_color(self.color)
        self.tip_point_index = -np.argmin(self.get_all_points()[-1, :])
Example #32
0
    def __init__(
        self,
        reactants: List[ChemObject] = [],
        products: List[ChemObject] = [],
        **arrow_kwargs,
    ):
        digest_config(self, arrow_kwargs)
        arrow = ChemArrow(
            self._type,
            self.length,
            self.angle,
            self.style,
            self.text_up,
            self.text_down,
        )

        r = self.get_side_of_equation(reactants)
        p = self.get_side_of_equation(products)

        self.set_same_height_for_all_mobjects(r)
        self.set_same_height_for_all_mobjects(p)
        self.set_same_height_for_all_mobjects([VGroup(*r), arrow, VGroup(*p)])

        VGroup.__init__(*[*r, arrow, *p])
Example #33
0
    def __init__(self, **kwargs):

        VGroup.__init__(self, **kwargs)
        self.create_boxes(self.resolution)
        self.mask_array = np.zeros(self.resolution)
        self.colors = color_gradient([BLUE_D, YELLOW, RED, RED_D], 110)
Example #34
0
 def __init__(self, key=None, **kwargs):
     VGroup.__init__(self, key=key, **kwargs)
Example #35
0
 def __init__(self, func, **kwargs):
     VGroup.__init__(self, **kwargs)
     self.setup_in_uv_space()
     self.apply_function(lambda p: func(p[0], p[1]))
     if self.should_make_jagged:
         self.make_jagged()
Example #36
0
 def __init__(self, key=None, **kwargs):
     VGroup.__init__(self, key=key, **kwargs)
Example #37
0
 def __init__(self, **kwargs):
     VGroup.__init__(self, **kwargs)
     self.x_axis = self.get_axis(self.x_min, self.x_max, self.x_axis_config)
     self.y_axis = self.get_axis(self.y_min, self.y_max, self.y_axis_config)
     self.y_axis.rotate(np.pi / 2, about_point=ORIGIN)
     self.add(self.x_axis, self.y_axis)
 def __init__(self, func, **kwargs):
     VGroup.__init__(self, **kwargs)
     self.setup_in_uv_space()
     self.apply_function(lambda p: func(p[0], p[1]))
     if self.should_make_jagged:
         self.make_jagged()
Example #39
0
 def __init__(self, vmobj,reverse=False, **kwargs):
     VGroup.__init__(self, reverse=False,**kwargs)
     [self.add(CurveLine(vmobj,i)) for i in range(vmobj.get_num_curves())]
Example #40
0
    def __init__(self, file_name=None, **kwargs):
        Container.__init__(self, **kwargs)
        self.file_name = file_name or self.file_name
        self.ensure_valid_file()
        self.style = self.style.lower()
        self.gen_html_string()
        strati = self.html_string.find("background:")
        self.background_color = self.html_string[strati + 12:strati + 19]
        self.gen_code_json()

        self.code = self.gen_colored_lines()
        if self.insert_line_no:
            self.line_numbers = self.gen_line_numbers()
            self.line_numbers.next_to(self.code,
                                      direction=LEFT,
                                      buff=self.line_no_buff)

        if self.background == "rectangle":
            if self.insert_line_no:
                forground = VGroup(self.code, self.line_numbers)
            else:
                forground = self.code
            self.background_mobject = SurroundingRectangle(
                forground,
                buff=self.margin,
                color=self.background_color,
                fill_color=self.background_color,
                stroke_width=0,
                fill_opacity=1,
            )
            self.background_mobject.round_corners(self.corner_radius)
        else:
            if self.insert_line_no:
                forground = VGroup(self.code, self.line_numbers)
            else:
                forground = self.code

            height = forground.get_height() + 0.1 * 3 + 2 * self.margin
            width = forground.get_width() + 0.1 * 3 + 2 * self.margin

            rrect = RoundedRectangle(corner_radius=self.corner_radius,
                                     height=height,
                                     width=width,
                                     stroke_width=0,
                                     color=self.background_color,
                                     fill_opacity=1)
            red_button = Dot(radius=0.1, stroke_width=0, color='#ff5f56')
            red_button.shift(LEFT * 0.1 * 3)
            yellow_button = Dot(radius=0.1, stroke_width=0, color='#ffbd2e')
            green_button = Dot(radius=0.1, stroke_width=0, color='#27c93f')
            green_button.shift(RIGHT * 0.1 * 3)
            buttons = VGroup(red_button, yellow_button, green_button)
            buttons.shift(
                UP * (height / 2 - 0.1 * 2 - 0.05) + LEFT *
                (width / 2 - 0.1 * 5 - self.corner_radius / 2 - 0.05))

            self.background_mobject = VGroup(rrect, buttons)
            x = (height - forground.get_height()) / 2 - 0.1 * 3
            self.background_mobject.shift(forground.get_center())
            self.background_mobject.shift(UP * x)

        if self.insert_line_no:
            VGroup.__init__(self, self.background_mobject, self.line_numbers,
                            *self.code, **kwargs)
        else:
            VGroup.__init__(self, self.background_mobject,
                            Dot(fill_opacity=0, stroke_opacity=0), *self.code,
                            **kwargs)

        self.move_to(np.array([0, 0, 0]))
Example #41
0
 def __init__(self, **kwargs):
     VGroup.__init__(self, **kwargs)
     self.setup()
     self.setup_axes()
     self.center()