A copy of a part, which moves to a different place while the part stays
The copy entity is inside a part. Its argument is the target: the id of
an element of the SVG file of a diagram, or the name of a part of a
formula. Its at option gives the steps
that show the copy, and its on entities give the states of the copy. The
as option gives the name of the copy. The default name is the id of the
part, @ and the target, such as arg@hole1.
expand/1 gives each copy its own Expresso.Element.Part. In a diagram,
the render puts a copy of the element of the source after the source. In a
formula, the render writes the copy as its own math element after the
formula, and the presenter script puts it on its source. The copy then
moves to its target with move_to. docs/part-copies.md gives the design.
Summary
Functions
Give each copy of a list of parts its own part
Give the part of each copy its move and the delay of that move
Types
@type t() :: %Expresso.Element.Copy{ __spark_metadata__: term(), as: String.t() | nil, at: Expresso.Overlay.t(), effect: atom() | nil, on: [Expresso.Element.On.t()], target: String.t() }
The struct of a copy entity
Functions
@spec expand([Expresso.Element.Part.t()]) :: {:ok, [Expresso.Element.Part.t()]} | {:error, String.t()}
Give each copy of a list of parts its own part
The part of a copy follows the part of its source. It has the name of the
copy as its id, the source in copy_of and the target in copy_to, and
the at, effect and on of the copy. A part entity with the name of a
copy adds its on entities, its effect and its copies to that copy, so a
copy can have copies. A copy of a copy gets the target of its source in
copy_start, because it fades in there.
The function returns an error for a copy to its own part, for two parts or
copies with the same name, for a part with the name of a copy and the at
option, and for a loop of copies.
iex> part = %Expresso.Element.Part{id: "arg", copies: [%Expresso.Element.Copy{target: "hole"}]}
iex> {:ok, [_part, copy]} = Expresso.Element.Copy.expand([part])
iex> {copy.id, copy.copy_of, copy.copy_to}
{"arg@hole", "arg", "hole"}
@spec moves(Expresso.Element.Part.t()) :: Expresso.Element.Part.t()
Give the part of each copy its move and the delay of that move
The move is an on entity with move_to the target, at each step of the
copy. A copy of a copy also moves to the target of its source before its
first step. At the first step of the copy, the custom property --move-delay
holds the time of the fade, so the copy fades in at its source and then
moves. The render calls this function after the transformer gives each
part its steps.