Morph

object Morph

The drawing at a moment between two Snapshots: what a transition shows while it plays.

A shape that is in both and has the same vertices in both (the same VertexIds, in the same order, in each ring) morphs: every vertex moves in a straight line to where it is in the second, and so do the size of a marker, the width of a line and the opacity or colour of a look. What has no middle (a text, an image, a list of properties, a look that changes kind) is the first one's up to the half way point and the second one's after it.

A polygon whose corners changed but share some (a merge adds the other shape's corners, a cut takes some away, a point was added or deleted) grows or shrinks: the corners it has in both stay or move straight, and the ones that are only in one slide along the outline to or from where they are in the other (see alignOutlines), so the shape starts as exactly the first outline and ends as exactly the second. That needs at least three corners in common, in the same order round both (either way round), and the same holes.

Any other shape crossfades. A shape that is in only one snapshot, or whose outline cannot be grown from the first into the second, cannot be moved vertex to vertex: the first fades out while the second fades in. The second of a pair like that is a copy under another id (the id with #to added), because both are on the map at once.

The result is in the order of the first snapshot, with what fades in after it in the order of the second. t is how far along it is: at 0 the result is exactly the first snapshot's shapes and at 1 exactly the second's, so a transition begins and ends on the real drawing.

Functions

Link copied to clipboard

The shapes at t of the way from from (0) to to (1): exactly from's shapes at 0 and to's at 1 (outside 0..1 the nearest end).