| 1 |
\documentclass[border=20pt]{standalone} |
| 2 |
\usepackage{svg-animate} |
| 3 |
|
| 4 |
%% ── Static housing (always visible, drawn outside animate) ─────────────────── |
| 5 |
|
| 6 |
\newcommand{\housing}{% |
| 7 |
\fill[black!80, rounded corners=6pt] (-1.2,-3.6) rectangle (1.2,3.6); |
| 8 |
\fill[black!50, rounded corners=4pt] (-1.0,-3.4) rectangle (1.0,3.4); |
| 9 |
\foreach \y in {-2.2, 0, 2.2} |
| 10 |
{ \fill[black!60] (0,\y) circle[radius=0.85]; } |
| 11 |
} |
| 12 |
|
| 13 |
%% ── Per-step content macros ────────────────────────────────────────────────── |
| 14 |
%% |
| 15 |
%% NOTE: \animstep must appear LITERALLY in each animate body — the +b |
| 16 |
%% collector does not expand macros before splitting on \animstep. |
| 17 |
%% Only the step *content* is factored into these macros. |
| 18 |
|
| 19 |
\newcommand{\stepOne}{% |
| 20 |
\reveal{% |
| 21 |
\fill[green!65!black] (0,-2.2) circle[radius=0.75]; |
| 22 |
\node[right, font=\sffamily, black!70] at (1.3,-2.2) {fr. 1}; |
| 23 |
}% |
| 24 |
} |
| 25 |
|
| 26 |
\newcommand{\stepTwo}{% |
| 27 |
\reveal{% |
| 28 |
\fill[orange!90!black] (0, 0.0) circle[radius=0.75]; |
| 29 |
}% |
| 30 |
%% Label shared with step 4: use step= key so it appears in both frames |
| 31 |
\reveal[step={2,4}]{% |
| 32 |
\node[right, font=\sffamily, black!70] at (1.3, 0.0) {fr. 2+4}; |
| 33 |
}% |
| 34 |
} |
| 35 |
|
| 36 |
\newcommand{\stepThree}{% |
| 37 |
\reveal{% |
| 38 |
\fill[red!85!black] (0, 2.2) circle[radius=0.75]; |
| 39 |
}% |
| 40 |
%% Label shared with step 4: use step= key so it appears in both frames |
| 41 |
\reveal[step={3,4}]{% |
| 42 |
\node[right, font=\sffamily, black!70] at (1.3, 2.2) {fr. 3+4}; |
| 43 |
}% |
| 44 |
%% Blinking marker: demonstrates blink= key. |
| 45 |
%% The static column is immune because it uses \begin{animate}[static]. |
| 46 |
\reveal[blink=0.3,]{% |
| 47 |
\node[fill=yellow!80, draw=orange!80!black, font=\sffamily, |
| 48 |
inner sep=2pt, rounded corners=2pt] at (0,-4.0) {fr. 3 — blink}; |
| 49 |
}% |
| 50 |
%% step={1-3}: visible in steps 1 to 3 — demonstrates range syntax |
| 51 |
\reveal[step={1-3}]{% |
| 52 |
\node[font=\sffamily, black!50] at (0,-5.6) {step=\{1-3\}}; |
| 53 |
}% |
| 54 |
%% Demonstrates blink off opacity: during step 3 the element blinks between |
| 55 |
%% blink on opacity=1 (visible) and blink off opacity=0.25 (dimmed), |
| 56 |
%% while inactive opacity=0 keeps it hidden between steps. |
| 57 |
\reveal[blink=0.3, inactive opacity=0, blink off opacity=0.25]{% |
| 58 |
\node[fill=yellow!80, draw=orange!80!black, font=\sffamily, |
| 59 |
inner sep=2pt, rounded corners=2pt] at (0,-6.2) {fr. 3 — dimmed blink}; |
| 60 |
}% |
| 61 |
|
| 62 |
} |
| 63 |
|
| 64 |
\newcommand{\stepFour}{% |
| 65 |
\reveal{% |
| 66 |
\fill[red!85!black] (0, 2.2) circle[radius=0.75]; |
| 67 |
}% |
| 68 |
\reveal{% |
| 69 |
\fill[orange!90!black] (0, 0.0) circle[radius=0.75]; |
| 70 |
}% |
| 71 |
%% step={1,2,3,4}: visible in every frame — demonstrates the step= key |
| 72 |
\reveal[step={1,2,3,4}]{% |
| 73 |
\node[font=\sffamily, black!50] at (0,-4.8) {step=\{1,2,3,4\}}; |
| 74 |
}% |
| 75 |
} |
| 76 |
|
| 77 |
\begin{document} |
| 78 |
\begin{tabular}{@{}c@{\qquad}c@{\qquad}c@{}} |
| 79 |
\small\texttt{loop=true} & |
| 80 |
\small\texttt{loop=false} & |
| 81 |
\small static (all steps) \\[6pt] |
| 82 |
|
| 83 |
%% ── Column 1 : loops forever ───────────────────────────────────────────── |
| 84 |
\begin{tikzpicture} |
| 85 |
\housing |
| 86 |
\begin{animate}[inactive opacity=0.08, duration=1.5] |
| 87 |
\stepOne |
| 88 |
\animstep |
| 89 |
\stepTwo |
| 90 |
\animstep[duration=0.5] |
| 91 |
\stepThree |
| 92 |
\animstep |
| 93 |
\stepFour |
| 94 |
\end{animate} |
| 95 |
\end{tikzpicture} |
| 96 |
|
| 97 |
& |
| 98 |
|
| 99 |
%% ── Column 2 : plays once, rests on \noanimate frame ───────────────────── |
| 100 |
\begin{tikzpicture} |
| 101 |
\housing |
| 102 |
\begin{animate}[inactive opacity=0.08, duration=1.5, loop=false] |
| 103 |
%% Resting state shown after the animation ends (SMIL fill=remove). |
| 104 |
\noanimate{% |
| 105 |
\foreach \y in {-2.2, 0, 2.2} |
| 106 |
{ \fill[black!35] (0,\y) circle[radius=0.75]; } |
| 107 |
\node[font=\sffamily, black!50] at (0,-4.2) {end state}; |
| 108 |
}% |
| 109 |
\stepOne |
| 110 |
\animstep |
| 111 |
\stepTwo |
| 112 |
\animstep[duration=0.5] |
| 113 |
\stepThree |
| 114 |
\animstep |
| 115 |
\stepFour |
| 116 |
\end{animate} |
| 117 |
\end{tikzpicture} |
| 118 |
|
| 119 |
& |
| 120 |
|
| 121 |
%% ── Column 3 : static — all steps at opacity 1 simultaneously ──────────── |
| 122 |
\begin{tikzpicture} |
| 123 |
\housing |
| 124 |
\begin{animate}[static] |
| 125 |
\stepOne |
| 126 |
\animstep |
| 127 |
\stepTwo |
| 128 |
\animstep[duration=0.5] |
| 129 |
\stepThree |
| 130 |
\animstep |
| 131 |
\stepFour |
| 132 |
\end{animate} |
| 133 |
\end{tikzpicture} |
| 134 |
|
| 135 |
\end{tabular} |
| 136 |
\end{document} |