from manim import *
from landscapebarchart import LandscapeBarChart
# Note that the y axis in this landscape bar chart will be horizontal, and the x_axis will be vertical
# Also when the documentation/code refers to bar heights, it will be actually the rectangle width,
Transform(a,b) |
ReplacementTransform(a,b) |
TransformFromCopy(a,b) |
|
---|---|---|---|
a initial shape |
a |
a |
a |
a final shape |
b |
b |
a (never changed) |
b initial shape |
b |
b |
a (temporarly) |
b final shape |
b (never changed) |
b (never changed) |
b |
In scene during transform | a (morphing into b ) |
a (morphing into b ) |
b (morphing from a's shape) |
In scene after transform | a (in the shape of b ) |
b |
b |
See illustrative video here -> https://gist.github.com/assets/44573666/71b711f1-88ab-4065-8aa9-a8c333ffaa29
The module code_utils.py
contains functions useful to deal with code.
Currently it only contains find_in_code()
function, described below
Finds all occurrences of the string string
in the code object code
,
optionally restricting the search to the lines specified in the lines
To be frank, I don't know all the details about making your own custom Animation class. I know only a general idea, but the details are fuzzy. I usually end up using a trial-and-error approach trying different methods and reading the source code of similar animations, until it works. But the main idea is:
- An animation receives a
mobject
(it can be a group) on which it will operate. In the__init__
method usually it only stores that object intoself.mobject
, so every animation has that object, and other animation attributes such as the run time, rate function, etc. - When used in a
.play()
, manim will call itsbegin()
method. Usually you don't need to override that. The default implementation creates another inner object calledself.starting_mobject
which stores the initial state of the mobject being animated, and it is simply a deep copy ofself.mobject
(although you can override how that starting mobject is created by overriding `create_starting_mobj
Manim provides few styles of arrow tips, basically a filled triangle and the "stealth".
This python module implements Latex-style arrow tips. The shape is a perfect copy of the one used by Computer Modern fonts.
It was produced by exporting to svg a latex document containing
This is an example of several arrows with several kinds of tips pointing in all directions (the code is the file example.py
in this gist.
The class OrthogonalConnection
creates a polyline that goes from p1 to p2, composed only by horizontal and vertical segments. The shape of the line is controlled by the path parameter.
There are two ways to use this class:
-
p1
andp2
are the start and end points of the line, and path is a string with the characters "-" and "|" indicating the horizontal and vertical segments of the line.For example
"-|-"
will start with a horizontal segment, that will go until the x coordinate intermediate betweenp1
andp2
, then a vertical segment up to the y coordinate ofp2
, and finally a horizontal segment top2
.
from typing import Iterable | |
def play_timeline(scene, timeline): | |
""" | |
Plays a timeline of animations on a given scene. | |
Args: | |
scene (Scene): The scene to play the animations on. | |
timeline (dict): A dictionary where the keys are the times at which the animations should start, | |
and the values are the animations to play at that time. The values can be a single animation |
""" | |
This module implements class LatexItems which is useful as an alternative | |
to manim's BulletedList. | |
Unless BulletedList, LatexItems uses standard latex itemize environment to | |
typeset the text and the bullets. The width of the paragraphs can be customized | |
as well as the kind of environment (itemize, enumerate, or description) | |
""" | |
from manim import Tex, TexTemplate |