常量部分 constants¶
manimlib
文件夹中的 constants.py
定义了在运行manim时需要的常量。
一些常量在这里没有说明,因为他们只在manim内部使用
画面和帧形状¶
ASPECT_RATIO = 16.0 / 9.0
FRAME_HEIGHT = 8.0
FRAME_WIDTH = FRAME_HEIGHT * ASPECT_RATIO
FRAME_Y_RADIUS = FRAME_HEIGHT / 2
FRAME_X_RADIUS = FRAME_WIDTH / 2
DEFAULT_PIXEL_HEIGHT = 1080
DEFAULT_PIXEL_WIDTH = 1920
DEFAULT_FRAME_RATE = 30
间距¶
SMALL_BUFF = 0.1
MED_SMALL_BUFF = 0.25
MED_LARGE_BUFF = 0.5
LARGE_BUFF = 1
DEFAULT_MOBJECT_TO_EDGE_BUFFER = MED_LARGE_BUFF # Distance between object and edge
DEFAULT_MOBJECT_TO_MOBJECT_BUFFER = MED_SMALL_BUFF # Distance between objects
动画默认运行时间¶
DEFAULT_POINTWISE_FUNCTION_RUN_TIME = 3.0
DEFAULT_WAIT_TIME = 1.0
坐标¶
manim 使用三维坐标,并且用 ndarray
的类型
ORIGIN = np.array((0., 0., 0.))
UP = np.array((0., 1., 0.))
DOWN = np.array((0., -1., 0.))
RIGHT = np.array((1., 0., 0.))
LEFT = np.array((-1., 0., 0.))
IN = np.array((0., 0., -1.))
OUT = np.array((0., 0., 1.))
X_AXIS = np.array((1., 0., 0.))
Y_AXIS = np.array((0., 1., 0.))
Z_AXIS = np.array((0., 0., 1.))
# Useful abbreviations for diagonals
UL = UP + LEFT
UR = UP + RIGHT
DL = DOWN + LEFT
DR = DOWN + RIGHT
TOP = FRAME_Y_RADIUS * UP
BOTTOM = FRAME_Y_RADIUS * DOWN
LEFT_SIDE = FRAME_X_RADIUS * LEFT
RIGHT_SIDE = FRAME_X_RADIUS * RIGHT
数学常数¶
PI = np.pi
TAU = 2 * PI
DEGREES = TAU / 360
RADIANS = 1 # 以弧度制作为单位
针对 OpenGL¶
JOINT_TYPE_MAP = {
"auto": 0,
"round": 1,
"bevel": 2,
"miter": 3,
}
针对 Text¶
NORMAL = "NORMAL"
ITALIC = "ITALIC"
OBLIQUE = "OBLIQUE"
BOLD = "BOLD"
线条宽度¶
DEFAULT_STROKE_WIDTH = 4
颜色¶
颜色相关工具和预览可以使用:颜色工具 - MK官网
这里是manim中定义的颜色的预览:(修改自 elteoremadebeethoven)
BLUE
BLUE_E
BLUE_D
BLUE_C
BLUE_B
BLUE_A
TEAL
TEAL_E
TEAL_D
TEAL_C
TEAL_B
TEAL_A
GREEN
GREEN_E
GREEN_D
GREEN_C
GREEN_B
GREEN_A
YELLOW
YELLOW_E
YELLOW_D
YELLOW_C
YELLOW_B
YELLOW_A
GOLD
GOLD_E
GOLD_D
GOLD_C
GOLD_B
GOLD_A
RED
RED_E
RED_D
RED_C
RED_B
RED_A
MAROON
MAROON_E
MAROON_D
MAROON_C
MAROON_B
MAROON_A
PURPLE
PURPLE_E
PURPLE_D
PURPLE_C
PURPLE_B
PURPLE_A
GREY
GREY_E
GREY_D
GREY_C
GREY_B
GREY_A
Others
WHITE
BLACK
GREY_BROWN
DARK_BROWN
LIGHT_BROWN
PINK
LIGHT_PINK
GREEN_SCREEN
ORANGE