Base class for all visual objects in manimR. Provides position,
color, opacity, visibility, and spatial query methods that all
objects inherit.
Public fields
id
Unique identifier
type
Object type string
position
Position vector (x, y, z)
rotation
Rotation in radians
scale_factor
Scale factor
color
Primary color (hex string)
opacity
Opacity (0 to 1)
visible
Whether the object is visible
z_index
Drawing order (higher = on top)
data
Additional object-specific data
updaters
List of updater functions called each frame
target
Target state for MoveToTarget animation
Methods
Method new()
Create a new MObject
Usage
MObject$new(
type = "mobject",
position = c(0, 0, 0),
color = "#FFFFFF",
opacity = 1
)
Arguments
type
Object type
position
Position vector
color
Color
opacity
Opacity
Method copy()
Create a deep copy with a new ID
Method get_center()
Get center position
Method get_bounding_box()
Get bounding box as list(min, max)
Usage
MObject$get_bounding_box()
Method get_left()
Get left edge point
Method get_right()
Get right edge point
Method get_top()
Get top edge point
Method get_bottom()
Get bottom edge point
Method get_corner()
Get corner point
Usage
MObject$get_corner(direction)
Arguments
direction
Direction vector (e.g., UR, DL)
Method get_width()
Get width of object
Method get_height()
Get height of object
Move to an absolute position
Arguments
point
Target position (2D or 3D)
Shift by a relative vector
Arguments
direction
Direction vector to shift by
Rotate by an angle
Usage
MObject$rotate(angle, about_point = NULL)
Arguments
angle
Angle in radians
about_point
Point to rotate around (default: center)
Scale by a factor
Usage
MObject$scale(factor, about_point = NULL)
Arguments
factor
Scale multiplier
about_point
Point to scale around (default: center)
Method next_to()
Position next to another object
Usage
MObject$next_to(other, direction = RIGHT, buff = MED_SMALL_BUFF)
Arguments
other
Another MObject or a point
direction
Direction (e.g., RIGHT, UP)
buff
Buffer distance
Method to_edge()
Move to the edge of the frame
Usage
MObject$to_edge(direction = LEFT, buff = MED_LARGE_BUFF)
Arguments
direction
Direction to the edge (e.g., LEFT, UP)
buff
Buffer from edge
Method to_corner()
Move to a corner of the frame
Usage
MObject$to_corner(direction = UL, buff = MED_LARGE_BUFF)
Arguments
direction
Corner direction (e.g., UL, DR)
buff
Buffer from corner
Method align_to()
Align to another object along an edge
Usage
MObject$align_to(other, direction)
Arguments
other
Another MObject
direction
Edge direction (e.g., UP aligns tops)
Method set_color()
Set the primary color
Method set_opacity()
Set opacity
Usage
MObject$set_opacity(opacity)
Arguments
opacity
New opacity (0-1)
Method match_color()
Match the color of another object
Usage
MObject$match_color(other)
Method add_updater()
Add an updater function
Usage
MObject$add_updater(func)
Arguments
func
Function taking (self, dt) called each frame
Method clear_updaters()
Remove all updaters
Method generate_target()
Generate a target copy for animation
Usage
MObject$generate_target()
Method clone()
The objects of this class are cloneable with this method.
Usage
MObject$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.