Skip to contents

Base class for all vector mobjects. Stores geometry as cubic Bezier control points in a (N x 3) matrix where every 4 rows define one curve. Supports hierarchical submobjects for grouping.

Super class

manimR::MObject -> VMobject

Public fields

points

Matrix of Bezier control points (N x 3, 4 per curve)

stroke_width

Stroke width in pixels

stroke_color

Stroke color (NULL uses self$color)

stroke_opacity

Stroke opacity (0-1)

fill_color

Fill color (NULL = no fill)

fill_opacity

Fill opacity (0-1)

submobjects

List of child VMobjects

Methods

Inherited methods


Method new()

Create a new VMobject

Usage

VMobject$new(
  position = c(0, 0, 0),
  color = "#FFFFFF",
  opacity = 1,
  stroke_width = DEFAULT_STROKE_WIDTH,
  fill_color = NULL,
  fill_opacity = 0,
  ...
)

Arguments

position

Position

color

Color

opacity

Opacity

stroke_width

Stroke width

fill_color

Fill color

fill_opacity

Fill opacity

...

Additional args passed to MObject


Method set_points()

Set points from a matrix

Usage

VMobject$set_points(points)

Arguments

points

Matrix (N x 2 or N x 3)


Method get_points()

Get points matrix

Usage

VMobject$get_points()


Method has_points()

Check if this VMobject has any points

Usage

VMobject$has_points()


Method clear_points()

Clear all points

Usage

VMobject$clear_points()


Method get_num_curves()

Get number of curves (4 points each)

Usage

VMobject$get_num_curves()


Method add_line()

Add a straight line as a cubic Bezier

Usage

VMobject$add_line(start, end)

Arguments

start

Start point (x, y, z)

end

End point (x, y, z)


Method add_cubic_bezier()

Add a cubic Bezier curve

Usage

VMobject$add_cubic_bezier(p0, p1, p2, p3)

Arguments

p0, p1, p2, p3

Control points


Method append_points()

Append another VMobject's points

Usage

VMobject$append_points(other)

Arguments

other

A VMobject


Method get_bounding_box()

Get bounding box computed from actual points

Usage

VMobject$get_bounding_box()


Method get_center()

Get center computed from bounding box

Usage

VMobject$get_center()


Method get_all_points()

Get all points including from submobjects

Usage

VMobject$get_all_points()


Method get_start()

Get the start point of the first curve

Usage

VMobject$get_start()


Method get_end()

Get the end point of the last curve

Usage

VMobject$get_end()


Method get_arc_length()

Get approximate arc length

Usage

VMobject$get_arc_length()


Method point_from_proportion()

Get point at proportion along the path

Usage

VMobject$point_from_proportion(proportion)

Arguments

proportion

Value in 0,1


Method get_draw_points()

Get interpolated points for drawing

Usage

VMobject$get_draw_points(precision = 10)

Arguments

precision

Samples per curve


Method set_fill()

Set fill color and opacity

Usage

VMobject$set_fill(color = NULL, opacity = NULL)

Arguments

color

Fill color (NULL to clear)

opacity

Fill opacity


Method set_stroke()

Set stroke color, width, and opacity

Usage

VMobject$set_stroke(color = NULL, width = NULL, opacity = NULL)

Arguments

color

Stroke color

width

Stroke width

opacity

Stroke opacity


Method set_style()

Set both fill and stroke style

Usage

VMobject$set_style(
  fill_color = NULL,
  fill_opacity = NULL,
  stroke_color = NULL,
  stroke_width = NULL,
  stroke_opacity = NULL
)

Arguments

fill_color

Fill color

fill_opacity

Fill opacity

stroke_color

Stroke color

stroke_width

Stroke width

stroke_opacity

Stroke opacity


Method set_color()

Override set_color to also set stroke

Usage

VMobject$set_color(color)

Arguments

color

New color


Method add()

Add child submobjects

Usage

VMobject$add(...)

Arguments

...

VMobjects to add as children


Method add_submobject()

Add a single submobject (alias for add)

Usage

VMobject$add_submobject(obj)

Arguments

obj

MObject to add as child


Method remove()

Remove a child submobject

Usage

VMobject$remove(obj)

Arguments

obj

The VMobject to remove


Method get_submobject()

Get a submobject by index

Usage

VMobject$get_submobject(i)

Arguments

i

Index (1-based)


Method move_to()

Move to position

Usage

VMobject$move_to(point)

Arguments

point

Target position


Method shift()

Shift by direction

Usage

VMobject$shift(direction)

Arguments

direction

Shift vector


Method rotate()

Rotate (applies to points directly)

Usage

VMobject$rotate(angle, about_point = NULL, axis = c(0, 0, 1))

Arguments

angle

Angle in radians

about_point

Center of rotation

axis

Rotation axis for 3D


Method scale()

Scale (applies to points directly)

Usage

VMobject$scale(factor, about_point = NULL)

Arguments

factor

Scale factor

about_point

Center of scaling


Method print()

Print VMobject summary

Usage

VMobject$print()


Method clone()

The objects of this class are cloneable with this method.

Usage

VMobject$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.