オブジェクト
オブジェクトは宣言してから使用する
円
circle = Circle(
radius=1.0, # 半径
color=BLUE,
fill_opacity=0.5 # 塗りつぶしの透明度(0.0~1.0)
)
正方形
square = Square(
side_length=2.0, # 一辺の長さ
color=RED
)
長方形
rectangle = Rectangle(
height=2.0, # 高さ
width=4.0, # 幅
color=GREEN
)
直線
line = Line(
start=[0, 0, 0], # 始点 (x, y, z)
end=[2, 2, 0], # 終点 (x, y, z)
color=YELLOW
)
多角形
polygon = Polygon(
[0, 0, 0], # 頂点1 (x, y, z)
[2, 0, 0], # 頂点2 (x, y, z)
[1, 2, 0], # 頂点3 これ以降続く
color=PURPLE
)
円弧
arc = Arc(
radius=1.0, # 半径
start_angle=0, # 開始角度(ラジアン)
angle=PI/2, # 描画する角度(ラジアン)
color=ORANGE
)
楕円
ellipse = Ellipse(
width=3.0, # 横幅
height=2.0, # 縦幅
color=PINK
)
点
dot = Dot(
point=[0, 0, 0], # 点の位置 (x, y, z)
color=WHITE,
radius=0.1 # 点の半径
)
テキスト
text = Text(
"Hello, Manim!", # 表示する文字列
font_size=36, # フォントサイズ
color=BLUE
)
数式
math_tex = MathTex(
"E=mc^2", # 数式(LaTeX形式で記述)
font_size=48, # フォントサイズ
color=YELLOW
)
グラフ(例: 関数 y = x^2)
axes = Axes(
x_range=[-3, 3, 1], # x軸の範囲と目盛り間隔
y_range=[-1, 9, 1], # y軸の範囲と目盛り間隔
axis_config={"color": BLUE}
)
graph = axes.plot(
lambda x: x**2, # 関数
color=RED
)
ベクトル
vector = Vector(
direction=[2, 1, 0], # ベクトルの向き (x, y, z)
color=GREEN
)
矩形波
square_wave = FunctionGraph(
lambda x: 1 if int(x) % 2 == 0 else -1, # 関数(例: 矩形波)
color=BLUE
)
点線
dash_line = DashedLine(
start=[-2, 0, 0], # 始点
end=[2, 0, 0], # 終点
color=RED
)
注釈
annotation = Annotation(
"注釈例", # 注釈テキスト
location=[1, 1, 0], # 注釈の位置
color=PURPLE
)