Skip to contents

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

Usage

MObject$copy()


Method get_center()

Get center position

Usage

MObject$get_center()


Method get_bounding_box()

Get bounding box as list(min, max)

Usage

MObject$get_bounding_box()


Method get_left()

Get left edge point

Usage

MObject$get_left()


Method get_right()

Get right edge point

Usage

MObject$get_right()


Method get_top()

Get top edge point

Usage

MObject$get_top()


Method get_bottom()

Get bottom edge point

Usage

MObject$get_bottom()


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

Usage

MObject$get_width()


Method get_height()

Get height of object

Usage

MObject$get_height()


Method move_to()

Move to an absolute position

Usage

MObject$move_to(point)

Arguments

point

Target position (2D or 3D)


Method shift()

Shift by a relative vector

Usage

MObject$shift(direction)

Arguments

direction

Direction vector to shift by


Method rotate()

Rotate by an angle

Usage

MObject$rotate(angle, about_point = NULL)

Arguments

angle

Angle in radians

about_point

Point to rotate around (default: center)


Method scale()

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

Usage

MObject$set_color(color)

Arguments

color

New 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)

Arguments

other

Another MObject


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

Usage

MObject$clear_updaters()


Method generate_target()

Generate a target copy for animation

Usage

MObject$generate_target()


Method print()

Print object summary

Usage

MObject$print()


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.