The geometry ismanim
The most important class of modules in themanim
With a rich assortment of built-in geometric shapes, the
This post starts with the simplestpoint (in space or time)Let's start. One by one.manim
The geometry module in the
manim
There are 3 main modules related to the midpoint:
-
Dot
: Generic Points -
LabeledDot
: some explanatory text could be added in the middle of the point -
AnnotationDot
: Use of points in annotated scenarios
Dot
Series inmanim
The locations in each module are roughly as shown in the diagram above.
1. Main parameters
point (in space or time)Comparatively simple, so there are not many parameters, mainly to control the size of the point, color, transparency and other attributes.Dot
Object:
Parameter name | typology | clarification |
---|---|---|
point | [float,float,float] | Coordinates of the point |
radius | float | radius of a point |
stroke_width | float | Bezel Thickness |
fill_opacity | float | transparency |
color | str | color |
LabeledDot
object, inherited fromDot
object containing theDot
properties in addition to that:
Parameter name | typology | clarification |
---|---|---|
label | str | Text content in points |
AnnotationDot
object, inherited fromDot
object containing theDot
properties in addition to that:
Parameter name | typology | clarification |
---|---|---|
stroke_color | str | Frame Color |
fill_color | str | Internal color |
2. Examples of use
all threepoint (in space or time)objects, the most usedDot
object, the following demonstrates the use of points with some examples.
2.1. size
harmonizepoint (in space or time)The size of the point is mainly the radius of the adjustment pointradius
。
d1 = Dot(radius=0.04)
d2 = Dot() # default dot radius
d3 = Dot(radius=0.24)
d4 = Dot(radius=0.32)
d5 = Dot(radius=0.64)
2.2 Colors
point (in space or time)(used form a nominal expression)color
property allows you to set the color.
d1 = Dot(color=RED)
d2 = Dot(color=GREEN)
d3 = Dot(color=BLUE)
d4 = Dot(color=YELLOW)
d5 = Dot(color=PURPLE)
2.3. labeling
point (in space or time)The label in the band requires the use of theLabeledDot
object, which has alabel
attribute can display letters and numbers in addition to the
Chinese and math formulas can also be displayed.
d1 = LabeledDot(
label=Text("Chinese", font_size=20),
)
d2 = LabeledDot(label="a^2")
d3 = LabeledDot(label="32")
d4 = LabeledDot(label="V_i")
label
attribute can't be entered directly in Chinese, it needs to be passed through theText
object to input Chinese;
To enter the formula, just typeLatex
Formatted strings are sufficient, and will be rendered as formulas on output.
2.4 Borders and interiors
AnnotationDot
object is used to annotate and label the video, it divides the points intoframecap (a poem)inside (part, section)Two parts.
The border can be set thick or thin, and each of these two parts can also be set a different color.
d1 = AnnotationDot(
stroke_width=2,
stroke_color=RED,
fill_color=GREEN,
)
d2 = AnnotationDot(
stroke_width=10,
stroke_color=BLUE,
fill_color=YELLOW,
)
d3 = AnnotationDot(
stroke_width=20,
stroke_color=YELLOW,
fill_color=RED,
)
d4 = AnnotationDot(
stroke_width=40,
stroke_color=GREEN,
fill_color=PURPLE,
)
stroke_width
Property SettingsframeThe thickness of thestroke_color
property sets the color of the outer frame.fill_color
Sets the color of the interior.
3. Annexes
The complete code for the article is on a web disk (),
Download at.Full Code (Access code: 6872)