case classAnimation(diagrams: Seq[Diagram]) extends Product with Serializable
The central type for producing animations — sequences of diagrams
Animations can be combined in parallel (using +) or in sequence (using chain).
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")
Linear Supertypes
Serializable, Serializable, Product, Equals, AnyRef, Any
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: