A style's motion parts resolved (spec/02 §3.10–§3.12): its transition, its animation,
and how an element enters and exits, each with its defaults in place. Motion is a
generated stylesheet, never a <style> element in the drawing: each distinct resolved
part is a class whose rule goes into the Frame's generated stylesheet (spec/10).
iex> Macaw.Frame.Style.Motion.transition(%{fill: %{duration: 400}})
[%{property: :fill, duration: 400, easing: :cubic_in_out}]
iex> Macaw.Frame.Style.Motion.animation(%{name: :pulse})
%{name: :pulse, duration: 1000, easing: :linear, iterations: :infinite, delay: 0}
Summary
Functions
An animation part with its defaults (§3.11): 1000 ms, :linear, :infinite, no
delay; nil for a part with no name, or with 0 iterations, which runs nothing.
A resolved style's motion parts in the form Macaw.Draw.IR.Motion draws them (spec/10
§1.5, §5): :transition as [{property, duration, easing}], :animation as
%{name, duration, easing, iterations, delay}, :enter and :exit as %{name, duration, easing}, each with its defaults in place; a part that moves nothing (a
transition of duration 0, an animation of 0 iterations) and one that does not read
are left out. The generated stylesheet and the SVG renderer's motion classes are both
written from these.
The pieces of an explosion (§3.12): the element's box cut into a 4 × 4 grid, piece i
flying outward from the box's center to (0.6 + 0.4·hᵢ)·(1.5·max(w, h) + 20) with
hᵢ = ((7·i) mod 16) / 15, turning by ((37·i) mod 90) − 45 degrees, so an explosion
is the same on every run and backend.
The keyframes of a built-in animation (§3.11), each {offset, properties}; :error for
a host's keyframes, which the host's stylesheet holds.
The motion parts of a style.
Whether a style carries a motion part, so its elements carry their rows' identity (§3.10).
An enter or exit part with its defaults (§3.12): 400 ms and :cubic_out;
{:error, [{[:name], {:enum, names}}]} for a name that is no built-in and no string.
A transition part as the properties it moves (§3.10): the part's own duration and
easing move all three, an entry per property moves that one alone; 300 ms and
:cubic_in_out when absent. A duration of 0 moves nothing.
Functions
An animation part with its defaults (§3.11): 1000 ms, :linear, :infinite, no
delay; nil for a part with no name, or with 0 iterations, which runs nothing.
A resolved style's motion parts in the form Macaw.Draw.IR.Motion draws them (spec/10
§1.5, §5): :transition as [{property, duration, easing}], :animation as
%{name, duration, easing, iterations, delay}, :enter and :exit as %{name, duration, easing}, each with its defaults in place; a part that moves nothing (a
transition of duration 0, an animation of 0 iterations) and one that does not read
are left out. The generated stylesheet and the SVG renderer's motion classes are both
written from these.
iex> Macaw.Frame.Style.Motion.drawn(%{transition: %{fill: %{duration: 400}}, fill: "red"})
%{transition: [{:fill, 400, :cubic_in_out}]}
iex> Macaw.Frame.Style.Motion.drawn(%{transition: %{duration: 0}})
%{}
@spec explode(term(), term()) :: [%{piece: 0..15, distance: float(), turn: integer()}] | {:error, list()}
The pieces of an explosion (§3.12): the element's box cut into a 4 × 4 grid, piece i
flying outward from the box's center to (0.6 + 0.4·hᵢ)·(1.5·max(w, h) + 20) with
hᵢ = ((7·i) mod 16) / 15, turning by ((37·i) mod 90) − 45 degrees, so an explosion
is the same on every run and backend.
iex> [first | _] = Macaw.Frame.Style.Motion.explode(10, 10)
iex> {first.distance, first.turn}
{21.0, -45}
The keyframes of a built-in animation (§3.11), each {offset, properties}; :error for
a host's keyframes, which the host's stylesheet holds.
iex> Macaw.Frame.Style.Motion.keyframes(:pulse)
{:ok, [{0, %{opacity: 1}}, {0.5, %{opacity: 0.35}}, {1, %{opacity: 1}}]}
@spec keys() :: [atom(), ...]
The motion parts of a style.
Whether a style carries a motion part, so its elements carry their rows' identity (§3.10).
An enter or exit part with its defaults (§3.12): 400 ms and :cubic_out;
{:error, [{[:name], {:enum, names}}]} for a name that is no built-in and no string.
A transition part as the properties it moves (§3.10): the part's own duration and
easing move all three, an entry per property moves that one alone; 300 ms and
:cubic_in_out when absent. A duration of 0 moves nothing.