What’s new¶
Usage changes of new version manim¶
There are many changes in the new version of manim, and here are only the changes that may have an impact at the code writing level.
Some of the changes here may not have any major impact on the use, and some changes that affect the use are not mentioned below.
This document is for reference only, see the source code for details.
Animation
Added
Fade
as the parent class ofFadeIn
andFadeOut
FadeIn
andFadeOut
can be passed inshift
andscale
parametersDeleted
FadeInFrom, FadeInFromDown, FadeOutAndShift, FadeOutAndShiftDown, FadeInFromLarge
, these can be usedFadeIn, FadeOut
to achieve the same effect more easilyAdded
FadeTransform
to cross fade between two objects, and subclassFadeTransformPieces
Added
CountInFrom(decimal_mob, source_number=0)
to countdecimal_mob
fromsource_number
to the current valueRotating
can directly pass inangle
andaxis
without writing keywordsangle=, axis=
Rotate
has become a subclass ofRotating
, and the distortion effect inTransform
will not appearRemoved
MoveCar
animationAdded
TransformMatchingShapes(mobject, target_mobject)
andTransformMatchingTex(mobject, target_mobject)
Camera
Removed all camera classes except
Camera
(MappingCamera
,MovingCamera
,MultiCamera
) and all functions inThreeDCamera
Implemented
CameraFrame
(as aMobject
)Can be called by
self.camera.frame
inScene
All methods of
Mobject
can be used, such as.shift()
,.scale()
, etc.Call
.to_default_state()
to place in the default positionSet the Euler angles of the camera by
.set_euler_angles(theta, phi, gamma)
Set three single Euler angles by
.set_theta(theta)
,.set_phi(phi)
,.set_gamma(gamma)
Use
.increment_theta(dtheta)
,.increment_phi(dphi)
,.increment_gamma(gamma)
to increase the three Euler angles by a certain value. Can be used to realize automatic rotationself.camera.frame.add_updater(lambda mob, dt: mob.increment_theta(0.1 * dt))
Camera
adds a light source, which is aPoint
, which can be called byself.camera.light_source
inScene
to move and so on. The default position is(- 10, 10, 10)
Delete
Container
Mobject
svg
relatedAdded
Checkmark
andExmark
Some unnecessary classes have been removed from
drawings.py
Removed
Code
andParagraph
(by mistake)TexMobject
is renamed toTex
,TextMobject
is renamed toTexText
font_size
has been added toTex
,TexText
andText
Tex
andTexText
addedisolate
, which is a list, which will be automatically split
Mobject
types
Added a new class
Surface
, which is the parent class ofParametricSurface
andTexturedSurface
.Added the group
SGroup
forSurface
Added
TexturedSurface(uv_surface, image_file, dark_image_file=None)
, whereuv_surface
is aSurface
,image_file
is the image to be posted, anddark_image_file
is the image to be posted in the dark (default andimage_file
is the same)Deleted
Mobject1D
,Mobject2D
,PointCloudDot
Added
DotCloud
(aPMobject
), which has been greatly optimizedRemoved
AbstractImageMobject
,ImageMobjectFromCamera
Removed
sheen
fromVMobject
Mobject
Added
gloss
andshadow
, which are the numbers between[0, 1]
respectively. There are four methods of.get_gloss()
,.set_gloss(gloss)
,.get_shadow()
,.set_shadow(shadow)
Added
.get_grid(n_rows, n_cols)
to copy into gridAdded
.set_color_by_code(glsl_code)
to use GLSL code to change the colorAdded
.set_color_by_xyz_func(glsl_snippet, min_value=-5.0, max_value=5.0, colormap="viridis")
to pass in GLSL expression in the form ofx,y,z
, the return value should be a floating point number
Coordinate system (including
Axes
,ThreeDAxes
,NumberPlane
,ComplexPlane
)No longer use
x_min
,x_max
,y_min
,y_max
, but usex_range
,y_range
as anp.array()
, containing three numbersnp.array([ Minimum, maximum, step size])
Added the abbreviation
.i2gp(x, graph)
of.input_to_graph_point(x, graph)
Added some functions of the original
GraphScene
Added
.get_v_line(point)
,.get_h_line(point)
to return the line frompoint
to the two coordinate axes, and specify the line type through the keyword argument ofline_func
(defaultDashedLine
)Added
.get_graph_label(graph, label, x, direction, buff, color)
to return the label added to the imageAdded
.get_v_line_to_graph(x, graph)
,.get_h_line_to_graph(x, graph)
to return the line from the point with the abscissa ofx
on thegraph
to the two- axis lineAdded
.angle_of_tangent(x, graph, dx=EPSILON)
, returns the inclination angle ofgraph
atx
Added
.slope_of_tangent(x, graph, dx=EPSILON)
, returns the slope of tangent line ofgraph
atx
Added
.get_tangent_line(x, graph, length=5)
to return the tangent line ofgraph
atx
Added
.get_riemann_rectangles(graph, x_range, dx, input_sample_type, ...)
to return Riemann rectangles (aVGroup
)
The attribute
number_line_config
ofAxes
is renamed toaxis_config
Axes
original.get_coordinate_labels(x_values, y_values)
method was renamed to.add_coordinate_labels(x_values, y_values)
(but it is not added to the screen).add_coordinate_labels(numbers)
ofComplexPlane
will directly add the coordinates to the screen
NumberLine
No longer use
x_min
,x_max
,tick_frequency
, but usex_range
, which is an array containing three numbers[min, max, step]
The original
label_direction
attribute changed to theline_to_number_direction
attributeReplace
tip_width
andtip_height
withtip_config
(dictionary) attributesThe original
exclude_zero_from_default
attribute is modified to thenumbers_to_exclude
attribute (default is None)The original
.add_tick_marks()
method was changed to the.add_ticks()
methodDelete the
.get_number_mobjects(*numbers)
method, only use the.add_numbers(x_values=None, excluding=None)
method
Three-dimensional objects
Added
SurfaceMesh(uv_surface)
, pass in aSurface
to generate its uv meshParametricSurface
no longer usesu_min, u_max, v_min, v_max
, but instead usesu_range, v_range
, which is a tuple ((min, max)
), andresolution
can be set larger, don’t worry Speed issueAdded
Torus
, controlled byr1, r2
keyword parametersAdded
Cylinder
, controlled byheight, radius
keyword parametersAdded
Line3D
(extremely thin cylinder), controlled by thewidth
keyword parameterAdded
Disk3D
, controlled byradius
keyword parameterAdd
Square3D
, controlled byside_length
keyword parameterImproved
Cube
andPrism
, the usage remains unchanged
Other objects
ParametricFunction
is renamed toParametricCurve
. Instead of usingt_min, t_max, step_size
, uset_range
, which is an array of three numbers ([t_min, t_max, step_size]
).dt
was renamed toepsilon
. Other usage remains unchangedAll
TipableVMobject
can pass intip_length
to control the style oftip
Line
adds.set_points_by_ends(start, end, buff=0, path_arc=0)
methodLine
added.get_projection(point)
to return the projection position ofpoint
on a straight lineArrow
adds three attributes ofthickness, tip_width_ratio, tip_angle
CubicBezier
is changed toa0, h0, h1, a1
, that is, only a third-order Bezier curve is supportedSquare
can be initialized directly by passing inside_length
instead of using the keywordside_length=
always_redraw(func, *args, **kwargs)
supports incoming parameters*args, **kwargs
The
digit_to_digit_buff
property ofDecimalNumber
has been renamed todigit_buff_per_font_unit
, and the.scale()
method has been improvedValueTracker
addsvalue_type
attribute, the default isnp.float64
Scene
Removed all functions of
GraphScene
(moved toonce_useful_constructs
),MovingCameraScene
,ReconfigurableScene
,SceneFromVideo
,ZoomedScene
, andThreeDScene
. Because these can basically be achieved by adjustingCameraFrame
(self.camera.frame
)Currently
SampleSpaceScene
andVectorScene
have not been changed for the new version, so it is not recommended to use (onlyScene
is recommended)Fix the export of gif, just use the
-i
option directlyAdded the
.interact()
method, during which the mouse and keyboard can be used to continue the interaction, which will be executed by default after the scene endsAdded
.embed()
method, open iPython terminal to enter interactive modeAdded
.save_state()
method to save the current state of the sceneAdded
.restore()
method to restore the entire scene to the saved state
utils
A series of functions related to second-order Bezier have been added to
utils/bezier.py
Added a function to read color map from
matplotlib
inutils/color.py
Added a series of related functions for processing folders/custom styles/object families
resize_array
,resize_preserving_order
,resize_with_interpolation
three functions have been added toutils/iterables.py
The definition of
smooth
is updated inutils/rate_functions.py
clip(a, min_a, max_a)
function has been added toutils/simple_functions.py
Some functions have been improved in
utils/space_ops.py
, some functions for space calculation, and functions for processing triangulation have been added
constants
Fixed the aspect ratio of the screen to 16:9
Deleted the old gray series (
LIGHT_GREY
,GREY
,DARK_GREY
,DARKER_GREY
), added a new series of grayGREY_A
~GREY_E