Location>code7788 >text

manim learning-by-doing - points

Popularity:49 ℃/2024-08-09 18:24:09

The geometry ismanimThe most important class of modules in themanimWith 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.manimThe geometry module in the

manimThere are 3 main modules related to the midpoint:

  1. Dot: Generic Points
  2. LabeledDot: some explanatory text could be added in the middle of the point
  3. AnnotationDot: Use of points in annotated scenarios


DotSeries inmanimThe 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.
DotObject:

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

LabeledDotobject, inherited fromDotobject containing theDotproperties in addition to that:

Parameter name typology clarification
label str Text content in points

AnnotationDotobject, inherited fromDotobject containing theDotproperties 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 usedDotobject, 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)colorproperty 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 theLabeledDotobject, which has alabelattribute 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")


labelattribute can't be entered directly in Chinese, it needs to be passed through theTextobject to input Chinese;
To enter the formula, just typeLatexFormatted strings are sufficient, and will be rendered as formulas on output.

2.4 Borders and interiors

AnnotationDotobject 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_widthProperty SettingsframeThe thickness of thestroke_colorproperty sets the color of the outer frame.fill_colorSets 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)