package diagram
- Alphabetic
- Public
- All
Type Members
-
case class
Animation(diagrams: Seq[Diagram]) extends Product with Serializable
The central type for producing animations — sequences of diagrams
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:
- By default, the adjacent frames are aligned to reduce the overall movement
of the tree nodes inside them. You can “anchor” the roots of one or more diagrams
to minimize their movement instead, while allowing everything else to move (in case
of several anchors in one frame, completely pinning all of them might not be possible).
To do that, use the
withAnchor
method for each diagram in question, and provide the same anchor id for the same diagram across different frames. - By default, colors are auto-assigned within each frame. However if you have
several diagrams in each frame and their number or order changes, you will want
to assign colors manually. You can do that by using the
withColor
diagram method and providing the same color palette index for the same diagram across different frames. - When combining several animations in parallel, you might want to prevent the trees
inside them from sharing nodes with the same ids. This can be achieved with the
namespacing functionality (see Diagram for more details). Just like with diagrams,
you can use the
toNamespace
method to adjust that for the entire animation.
Usage examples:
// Basic animation Animation .startWith(Queue(1)) .iterateWithIndex(2)((queue, i) => queue :+ (i + 1)) .build() // Configure how the diagram for each frame is produced Animation .startWith(Queue(1)) .iterateWithIndex(2)((queue, i) => queue :+ (i + 1)) .build(Diagram(_).withCaption("My Queue").withColor(2)) // Adding anchors Animation .startWith(Queue(1)) .iterateWithIndex(2)((queue, i) => queue :+ (i + 1)) .build(Diagram(_).withAnchor("queue").withCaption("This node is anchored!")) // Combining in parallel Animation .startWith(Queue(1)) .iterateWithIndex(2)((queue, i) => queue :+ (i + 1)) .build() .toNamespace("one") + Animation .startWith(Queue(10)) .iterateWithIndex(2)((queue, i) => queue :+ (10 * (i + 1))) .build() .toNamespace("two")
- By default, the adjacent frames are aligned to reduce the overall movement
of the tree nodes inside them. You can “anchor” the roots of one or more diagrams
to minimize their movement instead, while allowing everything else to move (in case
of several anchors in one frame, completely pinning all of them might not be possible).
To do that, use the
-
sealed
trait
Diagram extends AnyRef
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")