The central type for producing animations — sequences of diagrams
The central type for producing diagrams
The central type for producing diagrams
A Diagram can be either a Diagram.Single (a diagram of a single RefTree), or Diagram.Multiple — a diagram containing several trees.
Diagrams can be combined using the +
operator.
Each diagram is associated with a hierarchical namespace. This namespace scopes the ids of the trees in the diagram. Put simply, two List diagrams will share the same Nil tree node if they are in the same namespace, and will each have its own Nil node otherwise.
Diagrams can have “anchors” which prevent their root nodes from moving between adjacent animation frames. For more details see Animation.
Usage examples:
// no caption Diagram(Queue(1)) // automatically set caption to "Queue(1) :+ 2" Diagram.sourceCodeCaption(Queue(1) :+ 2) // use toString to get the caption, i.e. "Queue(1, 2)" Diagram.toStringCaption(Queue(1) :+ 2) // merge two diagrams, set captions manually Diagram(Queue(1)).withCaption("one") + Diagram(Queue(2)).withCaption("two") // isolate each diagram in its own namespace Diagram(Queue(1)).toNamespace("one") + Diagram(Queue(2)).toNamespace("two")
The central type for producing animations — sequences of diagrams
Animations can be combined in parallel (using
+
) or in sequence (usingchain
).While in most cases this library provides sane defaults, various techniques can be applied to ensure continuity between the frames:
withAnchor
method for each diagram in question, and provide the same anchor id for the same diagram across different frames.withColor
diagram method and providing the same color palette index for the same diagram across different frames.toNamespace
method to adjust that for the entire animation.Usage examples: