VMobject
(fill_color=None, fill_opacity=0.0, stroke_color=None, stroke_opacity=1.0, stroke_width=4, background_stroke_color='#000000', background_stroke_opacity=1.0, background_stroke_width=0, sheen_factor=0.0, sheen_direction=array([ 1.0, 1.0, 0.0]), close_new_points=False, pre_function_handle_to_anchor_scale_factor=0.01, make_smooth_after_applying_functions=False, background_image_file=None, shade_in_3d=False, tolerance_for_point_equality=1e06, n_points_per_cubic_curve=4, **kwargs)[source]¶Bases: manim.mobject.mobject.Mobject
Methods


Add cubic bezier curve to the path. 

Add a straight line from the last point of VMobject to the given point. 



Add Quadratic bezier curve to the path. 

Creates a smooth curve from given points and add it to the VMobject. 













Changes the anchor mode of the bezier curves. 







Determine if two points are close enough to be considered equal. 



Makes sure that points are either directed clockwise or counterclockwise. 

Returns the bezier tuples from an array of points. 



First arg can be either a color, or a tuple/list of colors. 

Returns the anchors of the curves forming the VMobject. 

Returns anchors1, handles1, handles2, anchors2, where (anchors1[i], handles1[i], handles2[i], anchors2[i]) will be four points defining a cubic bezier curve for any i in range(0, len(anchors1)) 











Uses 

Return the starting anchors of the bezier curves. 

If there are multiple colors (for gradient) this returns the first one 





If there are multiple opacities, this returns the first 









Returns the expression of the nth curve. 

Returns the points defining the nth curve of the vmobject. 

Returns the number of curves of the vmobject. 

The simplest 









Returns the start anchors of the bezier curves. 















Returns the subcurve of the VMobject between the interval [a, b]. 

Returns subpaths formed by the curves of the VMobject. 





Initializes the colors. 

Inserts n curves to the bezier curves of the vmobject. 

Given an array of k points defining a bezier curves (anchors and handles), returns points defining exactly k + n bezier curves. 













Get the bezier curve evaluated at a position P, where P is the point corresponding to the proportion defined by the given alpha. 

Given two bounds a and b, transforms the points of the self vmobject into the points of the vmobject passed as parameter with respect to the bounds. 

Reverts the point direction by inverting the point order. 

If the distance between a given handle point H and its associated anchor point A is d, then it changes H to be a distances factor*d away from A, but so that the line from A to H doesn’t change. 

Given two sets of anchors and handles, process them to set them as anchors and handles of the VMobject. 



Condition is function which takes in one arguments, (x, y, z). 







Given an array of points, set them as corner of the vmobject. 
















Attributes

Used to animate the application of a method. 

The depth of the mobject. 

The height of the mobject. 

The width of the mobject. 
add_cubic_bezier_curve_to
(handle1, handle2, anchor)[source]¶Add cubic bezier curve to the path.
NOTE : the first anchor is not a paramater as by default the end of the last subpath!
handle1 (np.ndarray) – first handle
handle2 (np.ndarray) – second handle
anchor (np.ndarray) – anchor
None
add_line_to
(point)[source]¶Add a straight line from the last point of VMobject to the given point.
end of the straight line.
point (numpy.ndarray) –
add_quadratic_bezier_curve_to
(handle, anchor)[source]¶Add Quadratic bezier curve to the path.
handle (numpy.ndarray) –
anchor (numpy.ndarray) –
add_smooth_curve_to
(*points)[source]¶Creates a smooth curve from given points and add it to the VMobject. If two points are passed in, the first is interpreted as a handle, the second as an anchor.
points (np.array) – Points (anchor and handle, or just anchor) to add a smooth curve from
ValueError – If 0 or more than 2 points are given.
change_anchor_mode
(mode)[source]¶Changes the anchor mode of the bezier curves. This will modify the handles.
There can be only two modes, “jagged”, and “smooth”.
For chaining purposes.
mode (str) –
consider_points_equals_2d
(p0, p1)[source]¶Determine if two points are close enough to be considered equal.
This uses the algorithm from np.isclose(), but expanded here for the 2D point case. NumPy is overkill for such a small question. :param p0: first point :type p0: np.ndarray :param p1: second point :type p1: np.ndarray
whether two points considered close.
bool
p0 (numpy.ndarray) –
p1 (numpy.ndarray) –
force_direction
(target_direction)[source]¶Makes sure that points are either directed clockwise or counterclockwise.
target_direction (str
) – Either "CW"
or "CCW"
.
gen_cubic_bezier_tuples_from_points
(points)[source]¶Returns the bezier tuples from an array of points.
self.points is a list of the anchors and handles of the bezier curves of the mobject (ie [anchor1, handle1, handle2, anchor2, anchor3 ..]) This algorithm basically retrieve them by taking an element every n, where n is the number of control points of the bezier curve.
points (np.ndarray) – Points from which control points will be extracted.
Bezier control points.
typing.Tuple
generate_rgbas_array
(color, opacity)[source]¶First arg can be either a color, or a tuple/list of colors. Likewise, opacity can either be a float, or a tuple of floats. If self.sheen_factor is not zero, and only one color was passed in, a second slightly light color will automatically be added for the gradient
get_anchors
()[source]¶Returns the anchors of the curves forming the VMobject.
The anchors.
np.ndarray
get_anchors_and_handles
()[source]¶Returns anchors1, handles1, handles2, anchors2, where (anchors1[i], handles1[i], handles2[i], anchors2[i]) will be four points defining a cubic bezier curve for any i in range(0, len(anchors1))
Iterable of the anchors and handles.
typing.Iterable[np.ndarray]
get_direction
()[source]¶Uses shoelace_direction()
to calculate the direction.
The direction of points determines in which direction the
object is drawn, clockwise or counterclockwise.
Examples
The default direction of a Circle
is counterclockwise:
>>> from manim import Circle
>>> Circle().get_direction()
'CCW'
Either "CW"
or "CCW"
.
str
get_end_anchors
()[source]¶Return the starting anchors of the bezier curves.
Starting anchors
np.ndarray
get_nth_curve_function
(n)[source]¶Returns the expression of the nth curve.
n (int) – index of the desired curve.
expression of the nth bezier curve.
typing.Callable[float]
get_nth_curve_points
(n)[source]¶Returns the points defining the nth curve of the vmobject.
n (int) – index of the desired bezier curve.
points defininf the nth bezier curve (anchors, handles)
np.ndarray
get_num_curves
()[source]¶Returns the number of curves of the vmobject.
number of curves. of the vmobject.
int
get_point_mobject
(center=None)[source]¶The simplest Mobject
to be transformed to or from self.
Should by a point of the appropriate type
get_start_anchors
()[source]¶Returns the start anchors of the bezier curves.
Starting anchors
np.ndarray
get_subcurve
(a, b)[source]¶Returns the subcurve of the VMobject between the interval [a, b]. The curve is a VMobject itself.
lowerbound
upperboud
The subcurve between of [a, b]
a (float) –
b (float) –
get_subpaths
()[source]¶Returns subpaths formed by the curves of the VMobject.
We define a subpath between two curve if one of their extreminities are coincidents.
subpaths.
typing.Tuple
init_colors
(propagate_colors=True)[source]¶Initializes the colors.
Gets called upon creation. This is an empty method that can be implemented by subclasses.
insert_n_curves
(n)[source]¶Inserts n curves to the bezier curves of the vmobject.
Number of curves to insert
for chaining.
n (int) –
insert_n_curves_to_point_list
(n, points)[source]¶Given an array of k points defining a bezier curves (anchors and handles), returns points defining exactly k + n bezier curves.
n (int) – Number of desired curves.
points (np.ndarray) – Starting points.
Points generated.
np.ndarray
point_from_proportion
(alpha)[source]¶Get the bezier curve evaluated at a position P, where P is the point corresponding to the proportion defined by the given alpha.
alpha (float) – Proportion.
Point evaluated.
np.ndarray
pointwise_become_partial
(vmobject, a, b)[source]¶Given two bounds a and b, transforms the points of the self vmobject into the points of the vmobject passed as parameter with respect to the bounds. Points here stand for control points of the bezier curves (anchors and handles)
vmobject (VMobject) – The vmobject that will serve as a model.
a (float) – upperbound.
b (float) – lowerbound
reverse_direction
()[source]¶Reverts the point direction by inverting the point order.
Returns self.
Examples
class ChangeOfDirection(Scene):
def construct(self):
ccw = RegularPolygon(5)
ccw.shift(LEFT).rotate
cw = RegularPolygon(5)
cw.shift(RIGHT).reverse_direction()
self.play(Create(ccw), Create(cw),
run_time=4)
scale_handle_to_anchor_distances
(factor)[source]¶If the distance between a given handle point H and its associated anchor point A is d, then it changes H to be a distances factor*d away from A, but so that the line from A to H doesn’t change. This is mostly useful in the context of applying a (differentiable) function, to preserve tangency properties. One would pull all the handles closer to their anchors, apply the function then push them out again.
factor used for scaling.
For chaining.
factor (float) –
set_anchors_and_handles
(anchors1, handles1, handles2, anchors2)[source]¶Given two sets of anchors and handles, process them to set them as anchors and handles of the VMobject.
anchors1[i], handles1[i], handles2[i] and anchors2[i] define the ith bezier curve of the vmobject. There are four hardcoded paramaters and this is a problem as it makes the number of points per cubic curve unchangeable from 4. (two anchors and two handles).
for chaining.
anchors1 (Iterable[float]) –
handles1 (Iterable[float]) –
handles2 (Iterable[float]) –
anchors2 (Iterable[float]) –
set_color
(color, family=True)[source]¶Condition is function which takes in one arguments, (x, y, z). Here it just recurses to submobjects, but in subclasses this should be further implemented based on the the inner workings of color
set_points_as_corners
(points)[source]¶Given an array of points, set them as corner of the vmobject.
To achieve that, this algorithm sets handles aligned with the anchors such that the resultant bezier curve will be the segment between the two anchors.
points (Iterable[float]) – Array of points that will be set as corners.
self. For chaining purposes.