在Scene的場景下,可以使用manim預制的一些基本的幾何形狀,這裡包括了線和圖形兩類,它們之間的繼承關系也在之前已經說明,這裡解釋一些圖形的畫法和主要參數。
1 圖形共有屬性- 對于線或者圖形,共有的屬性就是線的 寬度 , 顔色
- 所有線類的區分還在于是否有 箭頭
- 所有圖形所包含區域還有兩個屬性, 顔色 和 透明度
2.1 普通直線
普通直線的畫法,直接使用Line生成即可,給出始末位置,顔色和線的粗細,這裡顔色預定義值可在constants.py找到,如下。
g=Line(start=ORIGIN,end=3*UP+4*RIGHT,color=RED,stroke_width=3)

2.2 虛線
g=DashedLine(start=ORIGIN,end=3*UP+4*RIGHT,color=RED,stroke_width=3)
2.3 箭頭
g=Arrow(start=ORIGIN,end=3*UP+4*RIGHT,color=RED,stroke_width=3)
可以利用tipstyle參數,對tip進行設定。它是一個字典,該字典内參數和其它參數一緻,隻是僅僅作用在箭頭上而已,箭頭的長度用tip_length設定。
g1=Arrow(start=ORIGIN,end=3*UP+4*RIGHT,color=RED,stroke_width=3,
tip_style={"fill_opacity": 0.3,"fill_color": WHITE,
'stroke_color':BLUE,"stroke_width":5.0} ,tip_length=0.5,)
2.4 雙向箭頭
3.1 普通弧線
弧線有兩種實作方式,一種是給出圓心位置,半徑以及角度的區間值,例如:
Arc(arc_center=ORIGIN,start_angle=pi,angle=pi,color=RED,stroke_width=3)
或者指定好弧線的兩個端點的位置,以及轉過的角度。
g=ArcBetweenPoints(start=UP,end=LEFT,angle=pi/3,color=RED,stroke_width=3)
3.2 曲線箭頭
g1=CurvedArrow(UP,LEFT,angle=pi/3,color=RED,stroke_width=3,tip_length=0.4)
3.3 曲線雙向箭頭
g1=CurvedDoubleArrow(UP,LEFT,angle=pi/3,color=RED,stroke_width=3,tip_length=0.4)
4.1 普通圓形
普通圓形無非半徑,圓心,色彩,如下。
Circle(arc_center=UP+LEFT,radius=3,color=RED,stroke_width=3)
可以給封閉曲線内填充顔色和透明度:
Circle(arc_center=UP+LEFT,radius=3,color=RED,stroke_width=3,fill_color=WHITE,fill_opacity=0.3)
4.2 橢圓形
Ellipse(width=3,height=1,color=RED,stroke_width=3,fill_color=WHITE,fill_opacity=0.3)
4.3 環形
Annulus(inner_radius=1,outer_radius=3,color=RED,stroke_width=3,fill_color=WHITE,fill_opacity=0.3)
4.4 環形扇區
如果需要完整的扇形
Sector(start_angle=pi/3,angle=pi/2,outer_radius=3,color=RED,stroke_width=3,fill_color=WHITE,fill_opacity=0.3)
5.1 普通多邊形
多邊形隻需要給出頂點的位置即可,如下:
Polygon(RIGHT,UP,LEFT)
5.2 正規多邊形
RegularPolygon(n=5)