def __init__(self, mobject, **kwargs): VGroup.__init__(self, Line(consts.UP + consts.LEFT, consts.DOWN + consts.RIGHT), Line(consts.UP + consts.RIGHT, consts.DOWN + consts.LEFT), ) self.replace(mobject, stretch=True) self.set_stroke(self.stroke_color, self.stroke_width)
def __init__(self, func, **kwargs): VGroup.__init__(self, **kwargs) self.func = func self.setup_in_uv_space() self.apply_function(lambda p: func(p[0], p[1])) if self.should_make_jagged: self.make_jagged()
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(consts.FRAME_WIDTH - consts.MED_LARGE_BUFF) self.set_color_by_gradient(*self.gradient_colors)
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 ])
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()
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))
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 * consts.DEGREES, about_point=consts.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)
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)
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 * consts.RIGHT + y * consts.UP self.add(self.get_vector(point)) self.set_opacity(self.opacity)
def __init__(self, **kwargs): circle = Circle(color=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(consts.ORIGIN, 0.3 * consts.UP) self.minute_hand = Line(consts.ORIGIN, 0.6 * consts.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 )
def __init__(self, key=None, **kwargs): VGroup.__init__(self, key=key, **kwargs)