Reference: Objects
Shapes, lines, marks, groups and pictures.
Groups and the base objects
Text and maths are on Text, Tables and Matrices; axes and charts on Graphs and Charts.
VGroup(*mobjects): AGroupof outline objects; the usual way to group shapes.g[0]is the first member.Group(*mobjects): Holds objects together so they move, scale and fade as one.VMobject(fill_color=None, fill_opacity=0.0, stroke_color=None, stroke_width=DEFAULT_STROKE_WIDTH): An object drawn as outlines (every shape, text and graph); takes the style options.Mobject(): The base of every object. Its methods (below and on Methods) return the object, so they chain.
from pymations import *
shapes = VGroup(Circle(), Square(), Triangle()).arrange(RIGHT, buff=0.5)
play(Create(shapes))
Shapes
Circle(radius=1.0, color=RED): A circle, red unless you give a colour..surround(mobject, dim_to_match=0, stretch=False, buffer_factor=1.2): Resizes and moves the circle to go round another object.
Ellipse(width=2.0, height=1.0, color=RED): An oval,widthwide andheighttall.Dot(point=ORIGIN, radius=DEFAULT_DOT_RADIUS, stroke_width=0, fill_opacity=1.0, color=WHITE): A small solid dot at a point.SmallDot(radius=DEFAULT_SMALL_DOT_RADIUS): A smallerDot.AnnotationDot(radius=DEFAULT_DOT_RADIUS * 1.3, stroke_width=5, stroke_color=WHITE, fill_color=BLUE): A larger dot with an outline, for marking a point.LabeledDot(label, radius=None, buff=SMALL_BUFF): A dot with a label (text or maths) inside it.Square(side_length=2.0, color=WHITE): A square, white outline.Rectangle(color=WHITE, height=2.0, width=4.0): A rectangle, white outline.RoundedRectangle(corner_radius=0.5, color=WHITE, height=2.0, width=4.0): A rectangle with rounded corners.Triangle(): An equal-sided triangle, point up.RegularPolygon(n=6, radius=1.0, start_angle=None, color=BLUE): A polygon withnequal sides.Polygon(*vertices, color=BLUE): A closed shape through the corner points given.Star(n=5, outer_radius=1.0, inner_radius=None, density=2, start_angle=TAU / 4, color=BLUE): A star withnpoints.Annulus(inner_radius=1, outer_radius=2, fill_opacity=1, stroke_width=0, color=WHITE): A ring between two circles, filled.Arc(radius=1.0, start_angle=0, angle=TAU / 4, arc_center=ORIGIN): Part of a circle: fromstart_angle, turningangle.Sector(radius=1, angle=TAU / 4, start_angle=0, fill_opacity=1, stroke_width=0, color=WHITE, arc_center=ORIGIN): A slice of a disc (a pie slice).AnnularSector(inner_radius=1, outer_radius=2, angle=TAU / 4, start_angle=0, fill_opacity=1, stroke_width=0, color=WHITE, arc_center=ORIGIN): A slice of a ring.ArcBetweenPoints(start, end, angle=TAU / 4, radius=None): An arc from one point to another, bending byangle.CubicBezier(start_anchor, start_handle, end_handle, end_anchor): A curve fromstart_anchortoend_anchor, pulled towards the two handles.
from pymations import *
star = Star(color=YELLOW, fill_opacity=0.8)
slice = Sector(radius=1.5, angle=PI / 3, color=ORANGE).next_to(star, RIGHT)
play(DrawBorderThenFill(star), FadeIn(slice))
Lines and arrows
Line(start=LEFT, end=RIGHT, buff=0, path_arc=None): A straight line between two points or objects;buffleaves a gap at each end..put_start_and_end_on(start, end): Moves the line so it runs between two new points.
DashedLine(start=LEFT, end=RIGHT, buff=0, path_arc=None): A dashedLine.Arrow(start=LEFT, end=RIGHT, buff=MED_SMALL_BUFF, stroke_width=6): A line with an arrow tip at the end; stops 0.25 short of each end unlessbuff=0.DoubleArrow(start=LEFT, end=RIGHT, buff=MED_SMALL_BUFF, stroke_width=6): AnArrowwith tips at both ends.Vector(direction=RIGHT, buff=0): An arrow from the middle of the picture (ORIGIN) todirection.CurvedArrow(start_point, end_point): An arrow along an arc between two points.CurvedDoubleArrow(start_point, end_point): ACurvedArrowwith tips at both ends.TangentLine(vmob, alpha, length=1, d_alpha=1e-6): A line touching a curve at a proportionalphaof the way along it.DashedVMobject(vmobject, num_dashes=15, dashed_ratio=0.5, dash_offset=0, color=None, equal_lengths=True): A dashed copy of any outline object.
from pymations import *
a = Dot(LEFT * 3)
b = Dot(RIGHT * 3)
play(FadeIn(a, b), GrowArrow(Arrow(a, b)))
Angles
Angle(line1, line2, radius=None, quadrant=(1, 1), other_angle=False, dot=False, dot_radius=None, dot_distance=0.55, dot_color=WHITE, elbow=False): An arc marking the angle between two lines;elbow=Truedraws a square corner,dot=Trueadds a dot..get_value(degrees=False): The angle in radians (a value toawait).
RightAngle(line1, line2, length=None): A square-corner mark between two lines that meet at a right angle.Elbow(width=0.2, angle=0): A small right-angle mark.
from pymations import *
l1 = Line(ORIGIN, RIGHT * 3)
l2 = Line(ORIGIN, [2, 2, 0])
play(Create(l1), Create(l2))
play(Create(Angle(l1, l2, radius=0.8)))
Marking things
SurroundingRectangle(mobject, color=YELLOW, buff=SMALL_BUFF, corner_radius=0.0): A yellow box round an object (or a group).BackgroundRectangle(mobject, color=None, stroke_width=0, stroke_opacity=0, fill_opacity=0.75, buff=0): A dark panel behind an object, so it stays readable over a busy picture.Brace(mobject, direction=DOWN, buff=0.2): A curly brace along one side of an object..put_at_tip(mob, use_next_to=True, buff=MED_SMALL_BUFF): Moves an object to the brace's tip..get_text(*text): A text label at the brace's tip..get_tex(*tex): A maths label at the brace's tip.
BraceLabel(obj, text, brace_direction=DOWN, label_constructor=MathTex, font_size=DEFAULT_FONT_SIZE, buff=0.2): A brace and a maths label in one.BraceText(obj, text, label_constructor=Text): A brace and a text label in one.Underline(mobject, buff=SMALL_BUFF): A line under an object.Cross(mobject=None, stroke_color=RED, stroke_width=6.0, scale_factor=1.0): A red X over an object, for crossing it out.
Pictures
ImageMobject(filename_or_array, scale_to_resolution=1080, invert=False, image_mode="RGBA", corner_radius=0, border_color=None, border_width=0, shadow=None, crop=None, ops=None, remove_background=False, resize=None, trace=None): A picture from an image file, a web address orload_image(...); moves, scales and fades like any object. Prepare it on the way in:remove_background=True(Apple devices),resize=800,ops=[("crop", {...}), ("flip",)](every method);corner_radius,border_color,border_width,shadowandcropstyle it..set_corner_radius(radius): Rounds the picture's corners (radius in picture units). Pymations extra (not in Manim)..set_border(color=WHITE, width=DEFAULT_STROKE_WIDTH): Draws a border round the picture. Pymations extra (not in Manim)..crop(x0=0.0, y0=0.0, x1=1.0, y1=1.0): Keeps part of the picture: the box from(x0, y0)to(x1, y1), as fractions from the bottom-left (0 to 1). Pymations extra (not in Manim).
SVGMobject(file_name=None, should_center=True, height=2, width=None, color=None, opacity=None, fill_color=None, fill_opacity=None, stroke_color=None, stroke_opacity=None, stroke_width=None, svg_default=None, path_string_config=None, use_svg_cache=True, trace=None, ops=None, remove_background=False, resize=None): A drawing from an.svgfile (next to the.pyfile, or a web address), as outlines that can be drawn, coloured and morphed. Given a picture withtrace=True(ortrace={"colors": 5, "detail": "medium"}), it traces it into flat-colour shapes first.PycturesCanvas(width=4.0, height=3.0, draw=None, resolution=100): A Pyctures drawing placed in the scene:draw(ctx, t)paints it every frame, in pixels (resolutionper unit). Pymations extra (not in Manim)..ctx: Its 2D drawing surface, to draw on directly.
from pymations import *
photo = ImageMobject("product.png").scale_to_fit_height(4)
photo.set_corner_radius(0.3).set_shadow()
play(FadeIn(photo, shift=UP))
Product and explainer helpers
Ready-made pieces for product videos and explainers.
Card(width=4.0, height=2.5, fill=GREY_E, radius=0.25, shadow=True, stroke_color=None, stroke_width=0): A filled panel with rounded corners and a soft shadow, to put things on. Pymations extra (not in Manim).Callout(target, text, side=UR, distance=1.6, color=YELLOW, text_color=WHITE, font_size=28, box_color=BLACK, box_opacity=0.8, **text_kwargs): A label in a box with an arrow to a spot:Callout(button, "Tap here", side=UR). Pymations extra (not in Manim).Badge(text, color=BLUE, text_color=WHITE, font_size=24, **text_kwargs): A pill-shaped label:Badge("NEW"). Pymations extra (not in Manim).Highlight(mobject, color=YELLOW, style="box", buff=0.12, corner_radius=0.12, stroke_width=6): A box round something to look at;style="glow"makes it a soft glow. Pymations extra (not in Manim).Spotlight(mobject, opacity=0.75, buff=0.15, color=BLACK): Dims everything except one object. Pymations extra (not in Manim).LowerThird(title, subtitle=None, color=BLUE, text_color=WHITE, background=BLACK, background_opacity=0.65, font="", corner=DL, buff=0.6): A name strip for the bottom-left corner:LowerThird("Ada Lovelace", "Founder"). Pymations extra (not in Manim).EndCard(logo=None, title="", url=None, subtitle=None, font="", logo_height=1.6): The closing card: a logo, a title and a web address, centred. Pymations extra (not in Manim).
from pymations import *
card = Card(width=5, height=3)
badge = Badge("NEW").next_to(card, UP)
play(FadeIn(card), FadeIn(badge, shift=DOWN))
play(Create(Highlight(badge)))