typing

Custom type definitions used in Manim.

Note for developers

Around the source code there are multiple strings which look like this:

'''
[CATEGORY]
<category_name>
'''

All type aliases defined under those strings will be automatically classified under that category.

If you need to define a new category, respect the format described above.

Type Aliases

Primitive data types

class ManimFloat
np.float64

A double-precision floating-point value (64 bits, or 8 bytes), according to the IEEE 754 standard.

class ManimInt
np.int64

A long integer (64 bits, or 8 bytes).

It can take values between \(-2^{63}\) and \(+2^{63} - 1\), which expressed in base 10 is a range between around \(-9.223 \cdot 10^{18}\) and \(+9.223 \cdot 10^{18}\).

Color types

class ManimColorDType
ManimFloat

Data type used in ManimColorInternal: a double-precision float between 0 and 1.

class RGB_Array_Float
NDArray[ManimColorDType]

shape: (3,)

A numpy.ndarray of 3 floats between 0 and 1, representing a color in RGB format.

Its components describe, in order, the intensity of Red, Green, and Blue in the represented color.

class RGB_Tuple_Float
tuple[float, float, float]

shape: (3,)

A tuple of 3 floats between 0 and 1, representing a color in RGB format.

Its components describe, in order, the intensity of Red, Green, and Blue in the represented color.

class RGB_Array_Int
NDArray[ManimInt]

shape: (3,)

A numpy.ndarray of 3 integers between 0 and 255, representing a color in RGB format.

Its components describe, in order, the intensity of Red, Green, and Blue in the represented color.

class RGB_Tuple_Int
tuple[int, int, int]

shape: (3,)

A tuple of 3 integers between 0 and 255, representing a color in RGB format.

Its components describe, in order, the intensity of Red, Green, and Blue in the represented color.

class RGBA_Array_Float
NDArray[ManimColorDType]

shape: (4,)

A numpy.ndarray of 4 floats between 0 and 1, representing a color in RGBA format.

Its components describe, in order, the intensity of Red, Green, Blue and Alpha (opacity) in the represented color.

class RGBA_Tuple_Float
tuple[float, float, float, float]

shape: (4,)

A tuple of 4 floats between 0 and 1, representing a color in RGBA format.

Its components describe, in order, the intensity of Red, Green, Blue and Alpha (opacity) in the represented color.

class RGBA_Array_Int
NDArray[ManimInt]

shape: (4,)

A numpy.ndarray of 4 integers between 0 and 255, representing a color in RGBA format.

Its components describe, in order, the intensity of Red, Green, Blue and Alpha (opacity) in the represented color.

class RGBA_Tuple_Int
tuple[int, int, int, int]

shape: (4,)

A tuple of 4 integers between 0 and 255, representing a color in RGBA format.

Its components describe, in order, the intensity of Red, Green, Blue and Alpha (opacity) in the represented color.

class HSV_Array_Float
RGB_Array_Float

shape: (3,)

A numpy.ndarray of 3 floats between 0 and 1, representing a color in HSV (or HSB) format.

Its components describe, in order, the Hue, Saturation and Value (or Brightness) in the represented color.

class HSV_Tuple_Float
RGB_Tuple_Float

shape: (3,)

A tuple of 3 floats between 0 and 1, representing a color in HSV (or HSB) format.

Its components describe, in order, the Hue, Saturation and Value (or Brightness) in the represented color.

class ManimColorInternal
RGBA_Array_Float

shape: (4,)

Internal color representation used by ManimColor, following the RGBA format.

It is a numpy.ndarray consisting of 4 floats between 0 and 1, describing respectively the intensities of Red, Green, Blue and Alpha (opacity) in the represented color.

Point types

class PointDType
ManimFloat

Default type for arrays representing points: a double-precision floating point value.

class InternalPoint2D
NDArray[PointDType]

shape: (2,)

A 2-dimensional point: [float, float].

Note

This type alias is mostly made available for internal use, and only includes the NumPy type.

class Point2D
InternalPoint2D | tuple[float, float]

shape: (2,)

A 2-dimensional point: [float, float].

Normally, a function or method which expects a Point2D as a parameter can handle being passed a Point3D instead.

class InternalPoint2D_Array
NDArray[PointDType]

shape: (N, 2)

An array of InternalPoint2D objects: [[float, float], ...].

Note

This type alias is mostly made available for internal use, and only includes the NumPy type.

class Point2D_Array
InternalPoint2D_Array | tuple[Point2D, ...]

shape: (N, 2)

An array of Point2D objects: [[float, float], ...].

Normally, a function or method which expects a Point2D_Array as a parameter can handle being passed a Point3D_Array instead.

Please refer to the documentation of the function you are using for further type information.

class InternalPoint3D
NDArray[PointDType]

shape: (3,)

A 3-dimensional point: [float, float, float].

Note

This type alias is mostly made available for internal use, and only includes the NumPy type.

class Point3D
InternalPoint3D | tuple[float, float, float]

shape: (3,)

A 3-dimensional point: [float, float, float].

class InternalPoint3D_Array
NDArray[PointDType]

shape: (N, 3)

An array of Point3D objects: [[float, float, float], ...].

Note

This type alias is mostly made available for internal use, and only includes the NumPy type.

class Point3D_Array
InternalPoint3D_Array | tuple[Point3D, ...]

shape: (N, 3)

An array of Point3D objects: [[float, float, float], ...].

Please refer to the documentation of the function you are using for further type information.

Vector types

class Vector2D
NDArray[PointDType]

shape: (2,)

A 2-dimensional vector: [float, float].

Normally, a function or method which expects a Vector2D as a parameter can handle being passed a Vector3D instead.

Caution

Do not confuse with the Vector or Arrow VMobjects!

class Vector2D_Array
NDArray[PointDType]

shape: (M, 2)

An array of Vector2D objects: [[float, float], ...].

Normally, a function or method which expects a Vector2D_Array as a parameter can handle being passed a Vector3D_Array instead.

class Vector3D
NDArray[PointDType]

shape: (3,)

A 3-dimensional vector: [float, float, float].

Caution

Do not confuse with the Vector or Arrow3D VMobjects!

class Vector3D_Array
NDArray[PointDType]

shape: (M, 3)

An array of Vector3D objects: [[float, float, float], ...].

class VectorND
NDArray[PointDType]

shape (N,)

An \(N\)-dimensional vector: [float, ...].

Caution

Do not confuse with the Vector VMobject! This type alias is named “VectorND” instead of “Vector” to avoid potential name collisions.

class VectorND_Array
NDArray[PointDType]

shape (M, N)

An array of VectorND objects: [[float, ...], ...].

class RowVector
NDArray[PointDType]

shape: (1, N)

A row vector: [[float, ...]].

class ColVector
NDArray[PointDType]

shape: (N, 1)

A column vector: [[float], [float], ...].

Matrix types

class MatrixMN
NDArray[PointDType]

shape: (M, N)

A matrix: [[float, ...], [float, ...], ...].

class Zeros
MatrixMN

shape: (M, N)

A MatrixMN filled with zeros, typically created with numpy.zeros((M, N)).

Bézier types

class QuadraticBezierPoints
NDArray[PointDType] | tuple[Point3D, Point3D, Point3D]

shape: (3, 3)

A Point3D_Array of 3 control points for a single quadratic Bézier curve: [[float, float, float], [float, float, float], [float, float, float]].

class QuadraticBezierPoints_Array
NDArray[PointDType] | tuple[QuadraticBezierPoints, ...]

shape: (N, 3, 3)

An array of \(N\) QuadraticBezierPoints objects: [[[float, float, float], [float, float, float], [float, float, float]], ...].

class QuadraticBezierPath
Point3D_Array

shape: (3*N, 3)

A Point3D_Array of \(3N\) points, where each one of the \(N\) consecutive blocks of 3 points represents a quadratic Bézier curve: [[float, float, float], ...], ...].

Please refer to the documentation of the function you are using for further type information.

class QuadraticSpline
QuadraticBezierPath

shape: (3*N, 3)

A special case of QuadraticBezierPath where all the \(N\) quadratic Bézier curves are connected, forming a quadratic spline: [[float, float, float], ...], ...].

Please refer to the documentation of the function you are using for further type information.

class CubicBezierPoints
NDArray[PointDType] | tuple[Point3D, Point3D, Point3D, Point3D]

shape: (4, 3)

A Point3D_Array of 4 control points for a single cubic Bézier curve: [[float, float, float], [float, float, float], [float, float, float], [float, float, float]].

class CubicBezierPoints_Array
NDArray[PointDType] | tuple[CubicBezierPoints, ...]

shape: (N, 4, 3)

An array of \(N\) CubicBezierPoints objects: [[[float, float, float], [float, float, float], [float, float, float], [float, float, float]], ...].

class CubicBezierPath
Point3D_Array

shape: (4*N, 3)

A Point3D_Array of \(4N\) points, where each one of the \(N\) consecutive blocks of 4 points represents a cubic Bézier curve: [[float, float, float], ...], ...].

Please refer to the documentation of the function you are using for further type information.

class CubicSpline
CubicBezierPath

shape: (4*N, 3)

A special case of CubicBezierPath where all the \(N\) cubic Bézier curves are connected, forming a quadratic spline: [[float, float, float], ...], ...].

Please refer to the documentation of the function you are using for further type information.

class BezierPoints
Point3D_Array

shape: (PPC, 3)

A Point3D_Array of \(\text{PPC}\) control points (\(\text{PPC: Points Per Curve} = n + 1\)) for a single \(n\)-th degree Bézier curve: [[float, float, float], ...].

Please refer to the documentation of the function you are using for further type information.

class BezierPoints_Array
NDArray[PointDType] | tuple[BezierPoints, ...]

shape: (N, PPC, 3)

An array of \(N\) BezierPoints objects containing \(\text{PPC}\) Point3D objects each (\(\text{PPC: Points Per Curve} = n + 1\)): [[[float, float, float], ...], ...].

Please refer to the documentation of the function you are using for further type information.

class BezierPath
Point3D_Array

shape: (PPC*N, 3)

A Point3D_Array of \(\text{PPC} \cdot N\) points, where each one of the \(N\) consecutive blocks of \(\text{PPC}\) control points (\(\text{PPC: Points Per Curve} = n + 1\)) represents a Bézier curve of \(n\)-th degree: [[float, float, float], ...], ...].

Please refer to the documentation of the function you are using for further type information.

class Spline
BezierPath

shape: (PPC*N, 3)

A special case of BezierPath where all the \(N\) Bézier curves consisting of \(\text{PPC}\) Point3D objects (\(\text{PPC: Points Per Curve} = n + 1\)) are connected, forming an \(n\)-th degree spline: [[float, float, float], ...], ...].

Please refer to the documentation of the function you are using for further type information.

class FlatBezierPoints
NDArray[PointDType] | tuple[float, ...]

shape: (3*PPC*N,)

A flattened array of Bézier control points: [float, ...].

Function types

class FunctionOverride
Callable

Function type returning an Animation for the specified Mobject.

class PathFuncType
Callable[[Point3D, Point3D, float], Point3D]

Function mapping two Point3D objects and an alpha value to a new Point3D.

class MappingFunction
Callable[[Point3D], Point3D]

A function mapping a Point3D to another Point3D.

Image types

class Image
NDArray[ManimInt]

shape: (height, width) | (height, width, 3) | (height, width, 4)

A rasterized image with a height of height pixels and a width of width pixels.

Every value in the array is an integer from 0 to 255.

Every pixel is represented either by a single integer indicating its lightness (for greyscale images), an RGB_Array_Int or an RGBA_Array_Int.

class GrayscaleImage
Image

shape: (height, width)

A 100% opaque grayscale Image, where every pixel value is a ManimInt indicating its lightness (black -> gray -> white).

class RGBImage
Image

shape: (height, width, 3)

A 100% opaque Image in color, where every pixel value is an RGB_Array_Int object.

class RGBAImage
Image

shape: (height, width, 4)

An Image in color where pixels can be transparent. Every pixel value is an RGBA_Array_Int object.

Path types

class StrPath
str | PathLike[str]

A string or os.PathLike representing a path to a directory or file.

class StrOrBytesPath
str | bytes | PathLike[str] | PathLike[bytes]

A string, bytes or os.PathLike object representing a path to a directory or file.