# Best method to animate a step by step state space diagram construction in TikZ

## Introduction

A long time ago I started learning how to use TikZ and I created some not very well made diagrams. One of those diagrams is a state space representation of linear dynamical systems. When I discovered I could perform animations with TikZ I tried my best to animate that diagram as an explanation of one should think step by step to draw and to understand the diagram.

Recently I redesigned some old diagrams with new methods I learned and decided to create some animations, but I noticed I should also revise how to animate them, since they were different from the originals draws I made.

### Question

And now comes the decision-making point. What would be the best method to animate these diagrams, creating step by step, in diagrams where I create the nodes and then the connections between them (MWE 2 below)? How to create such step by step animation after a already read TikZ diagram?

I know asking for "The Best " is a little bit subjective and opinion based, but in this case, it just lacks me information to decide how to proceed and it would take a long time to learn by trial and error which method is more suitable.

Criteria for "The Best".

1. Less changes in the original TikZ drawn
2. Allowing step by step of the diagram in (almost) any order
3. Compiling fast (or not so long)

### Background

I've seen some possibilities with uncover, multido, creating multiple pages pdf and using \animategraphics, but I don't know which one would fit the best my needs.

As fas as I've read, I guess uncover seems to better fill my criteria.

### Original diagram and animation - MWE 1

This is the first method I created the animation. It is clumsy, I used \ifthenelse to define what is presented in ecah step, the code is long, I didn't know how to keep what have already been draw. It is a mess. (I don't even remember where I find the example I based this code).

MWE 1 follows:

\documentclass[border=5pt]{standalone}
\usepackage{amsmath,xifthen,tikz,animate}
\usetikzlibrary{calc}
\begin{document}
\begin{animateinline}[poster=last, controls]{1}
\multiframe{8}{ii=0+1}{% ii=0,1,...99 ; rj=9.9,9.8,...,0.0
\begin{tikzpicture}[very thick, every node/.style={font=\LARGE}];
\definecolor{dkg}{rgb}{0,0.5,0};
% ==========
\useasboundingbox (-6,-3) rectangle ++(20,8);
\node[blue, right] at (9.5,-0.5) {\Huge Step:\ii};

\draw (2.5,0) rectangle ++(2,2) coordinate(G)  node[pos=0.5] {\Huge{$\int$}};

\node at (-1,-1.5) {
\begin{tabular}{l}
$\dot{x} = A x + B u$ \\
$y = C x + D u$
\end{tabular}
};

\ifthenelse{\ii < 1}{
\draw [-latex, teal] (G)++(0,-1) -- ++(1,0) coordinate(X) node[above]{$x$} -- ++(1,0);
}{
\ifthenelse{\ii < 2}{
\draw [-latex, teal] (G)++(0,-1) -- ++(1,0) coordinate(X) node[above]{$x$} -- ++(1,0);
\draw (1,1) coordinate(S) circle (1/2);
\draw [-latex, orange] (S)++(1/2,0) -- ++(1,0) coordinate(E) node[midway, above]{$\dot{x}$};

}{
\ifthenelse{\ii < 3}{
\draw [-latex, teal] (G)++(0,-1) -- ++(1,0) coordinate(X) node[above]{$x$} -- ++(1,0);
\draw (1,1) coordinate(S) circle (1/2);
\draw [-latex, orange] (S)++(1/2,0) -- ++(1,0) coordinate(E) node[midway, above]{$\dot{x}$};

\draw (2.5,-2.5) coordinate(A) rectangle ++(2*1,2*1) node[pos=0.5]{$A$};
\draw [-latex, teal] (X) -- ++(0,-2.5) -- ++(-1,0);

}{
\ifthenelse{\ii < 4}{
\draw [-latex, teal] (G)++(0,-1) -- ++(1,0) coordinate(X) node[above]{$x$} -- ++(1,0);
\draw (1,1) coordinate(S) circle (1/2);
\draw [-latex, orange] (S)++(1/2,0) -- ++(1,0) coordinate(E) node[midway, above]{$\dot{x}$};

\draw (2.5,-2.5) coordinate(A) rectangle ++(2*1,2*1) node[pos=0.5]{$A$};
\draw [-latex, teal] (X) -- ++(0,-2.5) -- ++(-1,0);

\draw [-latex, cyan] ($(A)+(0,1)$) -| ($(S)+(0,-0.5)$) node[below right]{$+$};
}{
\ifthenelse{\ii < 5}{
\draw [-latex, teal] (G)++(0,-1) -- ++(1,0) coordinate(X) node[above]{$x$} -- ++(1,0);
\draw (1,1) coordinate(S) circle (1/2);
\draw [-latex, orange] (S)++(1/2,0) -- ++(1,0) coordinate(E) node[midway, above]{$\dot{x}$};

\draw (2.5,-2.5) coordinate(A) rectangle ++(2*1,2*1) node[pos=0.5]{$A$};
\draw [-latex, teal] (X) -- ++(0,-2.5) -- ++(-1,0);

\draw [-latex, cyan] ($(A)+(0,1)$) -| ($(S)+(0,-0.5)$) node[below right]{$+$};

\draw (-2.5,0) rectangle ++(2*1,2*1) coordinate(B) node[pos=0.5]{$B$};
\draw [-latex, red] (B)++(0,-1) -- ++(1,0) node[above left]{$+$};
\draw [-latex, dkg] (-4,1) coordinate(u) node[above]{$u$} |- ++(1.5,0);

}{
\ifthenelse{\ii < 6}{
\draw [-latex, teal] (G)++(0,-1) -- ++(1,0) coordinate(X) node[above]{$x$} -- ++(1,0);
\draw (1,1) coordinate(S) circle (1/2);
\draw [-latex, orange] (S)++(1/2,0) -- ++(1,0) coordinate(E) node[midway, above]{$\dot{x}$};

\draw (2.5,-2.5) coordinate(A) rectangle ++(2*1,2*1) node[pos=0.5]{$A$};
\draw [-latex, teal] (X) -- ++(0,-2.5) -- ++(-1,0);

\draw [-latex, cyan] ($(A)+(0,1)$) -| ($(S)+(0,-0.5)$) node[below right]{$+$};

\draw (-2.5,0) rectangle ++(2*1,2*1) coordinate(B) node[pos=0.5]{$B$};
\draw [-latex, red] (B)++(0,-1) -- ++(1,0) node[above left]{$+$};
\draw [-latex, dkg] (-4,1) coordinate(u) node[above]{$u$} |- ++(1.5,0);

\draw (6.5,0) coordinate(C) rectangle ++(2*1,2*1) node[pos=0.5]{$C$};
\draw (10.5,1) coordinate(y) circle (1/2);
\draw [-latex, violet] (y)++(0.5,0) -- ++(1,0) node[above]{$y$};
\draw [-latex, olive] ($(C)+(2*1,1)$) -- ($(y)+(-0.5,0)$) node[above left]{$+$};

}{
\ifthenelse{\ii < 7}{
\draw [-latex, teal] (G)++(0,-1) -- ++(1,0) coordinate(X) node[above]{$x$} -- ++(1,0);
\draw (1,1) coordinate(S) circle (1/2);
\draw [-latex, orange] (S)++(1/2,0) -- ++(1,0) coordinate(E) node[midway, above]{$\dot{x}$};

\draw (2.5,-2.5) coordinate(A) rectangle ++(2*1,2*1) node[pos=0.5]{$A$};
\draw [-latex, teal] (X) -- ++(0,-2.5) -- ++(-1,0);

\draw [-latex, cyan] ($(A)+(0,1)$) -| ($(S)+(0,-0.5)$) node[below right]{$+$};

\draw (-2.5,0) rectangle ++(2*1,2*1) coordinate(B) node[pos=0.5]{$B$};
\draw [-latex, red] (B)++(0,-1) -- ++(1,0) node[above left]{$+$};
\draw [-latex, dkg] (-4,1) coordinate(u) node[above]{$u$} |- ++(1.5,0);

\draw (6.5,0) coordinate(C) rectangle ++(2*1,2*1) node[pos=0.5]{$C$};
\draw (10.5,1) coordinate(y) circle (1/2);
\draw [-latex, violet] (y)++(0.5,0) -- ++(1,0) node[above]{$y$};
\draw [-latex, olive] ($(C)+(2*1,1)$) -- ($(y)+(-0.5,0)$) node[above left]{$+$};

\draw (2.5,2.5) coordinate(D) rectangle ++(2*1,2*1) coordinate(B)  node[pos=0.5]{$D$};
\draw [-latex, dkg] ($(u)+(0.5*1,0)$) |- ($(D)+(0,1)$);
\draw [-latex, cyan] ($(D)+(2*1,1)$) -| ($(y)+(0,0.5)$) node[above right]{$+$};
}{
\draw [-latex, teal] (G)++(0,-1) -- ++(1,0) coordinate(X) node[above]{$x$} -- ++(1,0);
\draw (1,1) coordinate(S) circle (1/2);
\draw [-latex, orange] (S)++(1/2,0) -- ++(1,0) coordinate(E) node[midway, above]{$\dot{x}$};

\draw (2.5,-2.5) coordinate(A) rectangle ++(2*1,2*1) node[pos=0.5]{$A$};
\draw [-latex, teal] (X) -- ++(0,-2.5) -- ++(-1,0);

\draw [-latex, cyan] ($(A)+(0,1)$) -| ($(S)+(0,-0.5)$) node[below right]{$+$};

\draw (-2.5,0) rectangle ++(2*1,2*1) coordinate(B) node[pos=0.5]{$B$};
\draw [-latex, red] (B)++(0,-1) -- ++(1,0) node[above left]{$+$};
\draw [-latex, dkg] (-4,1) coordinate(u) node[above]{$u$} |- ++(1.5,0);

\draw (6.5,0) coordinate(C) rectangle ++(2*1,2*1) node[pos=0.5]{$C$};
\draw (10.5,1) coordinate(y) circle (1/2);
\draw [-latex, violet] (y)++(0.5,0) -- ++(1,0) node[above]{$y$};
\draw [-latex, olive] ($(C)+(2*1,1)$) -- ($(y)+(-0.5,0)$) node[above left]{$+$};

\draw (2.5,2.5) coordinate(D) rectangle ++(2*1,2*1) coordinate(B)  node[pos=0.5]{$D$};
\draw [-latex, dkg] ($(u)+(0.5*1,0)$) |- ($(D)+(0,1)$);
\draw [-latex, cyan] ($(D)+(2*1,1)$) -| ($(y)+(0,0.5)$) node[above right]{$+$};

\draw [very thick, red] (-3,-3) coordinate(eq) rectangle ++(12,8);
}}}}}}}
\end{tikzpicture}
}
\end{animateinline}
\end{document}

The result is as follows.

### New diagram to animated - MWE 2

This new diagram uses some personal local defined /.styles and is much better organized. Nodes are defined first and then connections are made. The code is clean, easy to change, much better than the older one. But I don't how the best way to animate it.

MWE 2 follows:

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
minimum size={#5 mm}, %minimum height=10mm,
path picture={
\draw[#6]
(path picture bounding box.south east) -- (path picture bounding box.north west)
(path picture bounding box.south west) -- (path picture bounding box.north east);
\node at ($(path picture bounding box.south)!0.4!(path picture bounding box.center)$) {#1};
\node at ($(path picture bounding box.west)!0.4!(path picture bounding box.center)$)  {#2};
\node at ($(path picture bounding box.north)!0.4!(path picture bounding box.center)$) {#3};
\node at ($(path picture bounding box.east)!0.4!(path picture bounding box.center)$)  {#4};
}
},
}
\tikzset{mySimpleArrow/.style n args={2}{
>={latex[#1]},
every path/.style={draw=#2}
},
mySimpleArrow/.default={black}{black}
}
\tikzset{myBlockOpacity/.style n args={4}{
every node/.style={rectangle,draw, text=black,
minimum width=#1, minimum height=#2,
fill opacity=#3, text opacity=#4}
},
myBlockOpacity/.default={1cm}{1cm}{0.4}{1}
}

\begin{document}
\begin{tikzpicture}[very thick]
\begin{scope}
\node[circle,draw,addCross={$+$}{$+$}{}{}{10}{black}] (N1) at (1,-0.5) {};
\end{scope}

\begin{scope}[shift={(3.0,-0.5)},myBlockOpacity]
\node[fill=red] (A) at (0,-1.5) {$A$};
\node[fill=green!50!black] (B) at (-4,0) {$B$};
\node[fill=yellow!75!black] (C) at (3,0) {$C$};
\node (I) at (0,0) {$\displaystyle \int$};
\end{scope}

\begin{scope}[mySimpleArrow={blue}{cyan}]
\path[->] (-2.5,-0.5) node[above]{$u$} -- (B);
\path[->] (B) -- (N1);
\path[->] (N1) -- (I) node[midway, above] {$\dot{x}$};

\path[->] (I) -- (4.5,-0.5) coordinate(x) node[above]{$x$} -- (C);
\path[->] (x) |- (A) -| (N1);
\path[->] (C) -- ++(1.5,0) node[above]{$y$};
\end{scope}
\end{tikzpicture}
\end{document}

which produces

• at least there is one simple way: animate by beamer's command on slide, etc. Commented Apr 29, 2022 at 6:20

An off-beamerclass \uncover command is defined, that specifies the frame number at which an object in a tikzpicture is to be revealed.

%\uncover{<current>}{<when>}{...<commands>...}
\newcommand\uncover[3]{\ifnum#1<#2\phantom{#3}\else#3\fi}

It relies on the \phantom{...}command which prevents the object from being drawn, yet evaluates coordinate definitions and even TikZ's automatic bounding box calculations. This allows us to reference node coordinates of hidden objects without changing too much of the original code.

\documentclass[border=10pt]{standalone}
\usepackage{animate}
\usepackage{tikz}
\usetikzlibrary{calc}
minimum size={#5 mm}, %minimum height=10mm,
path picture={
\draw[#6]
(path picture bounding box.south east) -- (path picture bounding box.north west)
(path picture bounding box.south west) -- (path picture bounding box.north east);
\node at ($(path picture bounding box.south)!0.4!(path picture bounding box.center)$) {#1};
\node at ($(path picture bounding box.west)!0.4!(path picture bounding box.center)$)  {#2};
\node at ($(path picture bounding box.north)!0.4!(path picture bounding box.center)$) {#3};
\node at ($(path picture bounding box.east)!0.4!(path picture bounding box.center)$)  {#4};
}
},
}
\tikzset{mySimpleArrow/.style n args={2}{
>={latex[#1]},
every path/.style={draw=#2}
},
mySimpleArrow/.default={black}{black}
}
\tikzset{myBlockOpacity/.style n args={4}{
every node/.style={rectangle,draw, text=black,
minimum width=#1, minimum height=#2,
fill opacity=#3, text opacity=#4}
},
myBlockOpacity/.default={1cm}{1cm}{0.4}{1}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\uncover{<current>}{<when>}{...}
\newcommand\uncover[3]{\ifnum#1<#2\phantom{#3}\else#3\fi}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}
\begin{animateinline}[step,controls=step]{1}
\multiframe{13}{i=0+1}{
\begin{tikzpicture}[very thick]
\begin{scope}
\uncover{\i}{4}{\node[circle,draw,addCross={$+$}{$+$}{}{}{10}{black}] (N1) at (1,-0.5) {};}
\end{scope}

\begin{scope}[shift={(3.0,-0.5)},myBlockOpacity]
\uncover{\i}{9}{\node[fill=red] (A) at (0,-1.5) {$A$};}
\uncover{\i}{2}{\node[fill=green!50!black] (B) at (-4,0) {$B$};}
\uncover{\i}{11}{\node[fill=yellow!75!black] (C) at (3,0) {$C$};}
\uncover{\i}{6}{\node (I) at (0,0) {$\displaystyle \int$};}
\end{scope}

\begin{scope}[mySimpleArrow={blue}{cyan}]
\uncover{\i}{1}{\path[->] (-2.5,-0.5) node[above]{$u$} -- (B);}
\uncover{\i}{3}{\path[->] (B) -- (N1);}
\uncover{\i}{5}{\path[->] (N1) -- (I) node[midway, above] {$\dot{x}$};}

\uncover{\i}{7}{\path[->] (I) -- (4.5,-0.5) coordinate(x) node[above]{$x$} -- (C);}
\uncover{\i}{8}{\path[->] (x) |- (A);}
\uncover{\i}{10}{\path[->] (A) -| (N1);}
\uncover{\i}{12}{\path[->] (C) -- ++(1.5,0) node[above]{$y$};}
\end{scope}
\end{tikzpicture}
}
\end{animateinline}
\end{document}
• What is the reason for off-beamer class?
– Tom
Commented Apr 29, 2022 at 10:02
• \uncover is a beamer-class command for step-wise revealing content, afaik. Commented Apr 29, 2022 at 10:04
• OK, I see. Thank you.
– Tom
Commented Apr 29, 2022 at 10:06
• Well played \uncover{\i}{4}{code}. It is very short, simple and can be easily added to any other TikZ diagram.
– FHZ
Commented Apr 29, 2022 at 16:14

I don't know if this is ideal for you. Because I change some of your tikz code in order to use a absolute coordinate for each path. In this way, each individual path can be drawn without reference the coordinate in other path. You can freely decide which path to be included in which frame. Using the \ifnum\i>'some frame number' in front of the path to decide if this path will be included in the next frame (some frame number+1). Here is the code:

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{animate}
minimum size={#5 mm}, %minimum height=10mm,
path picture={
\draw[#6]
(path picture bounding box.south east) -- (path picture bounding box.north west)
(path picture bounding box.south west) -- (path picture bounding box.north east);
\node at ($(path picture bounding box.south)!0.4!(path picture bounding box.center)$) {#1};
\node at ($(path picture bounding box.west)!0.4!(path picture bounding box.center)$)  {#2};
\node at ($(path picture bounding box.north)!0.4!(path picture bounding box.center)$) {#3};
\node at ($(path picture bounding box.east)!0.4!(path picture bounding box.center)$)  {#4};
}
},
}
\tikzset{mySimpleArrow/.style n args={2}{
>={latex[#1]},
every path/.style={draw=#2}
},
mySimpleArrow/.default={black}{black}
}
\tikzset{myBlockOpacity/.style n args={4}{
every node/.style={rectangle,draw, text=black,
minimum width=#1, minimum height=#2,
fill opacity=#3, text opacity=#4}
},
myBlockOpacity/.default={1cm}{1cm}{0.4}{1}
}

\begin{document}
\begin{animateinline}[autoplay,loop,poster=last, controls]{1}
\multiframe{13}{i=0+1}{
\begin{tikzpicture}[line width=1pt]
\fill [transparent] (-3,0.5) rectangle (8.5,-3);% at frame 1 (when i=0) just draw a transparent background
\ifnum\i>0\node (step) at (6,-2.5) {Step \i};\fi % start from frame 2 there will be label "step \i"
\begin{scope}
\ifnum\i>3\node[circle,draw,addCross={$+$}{$+$}{}{}{10}{black}] (N1) at (1,-0.5) {};\fi
\end{scope}

\begin{scope}[myBlockOpacity]
\ifnum\i>8\node[fill=red] (A) at (3,-2) {$A$};\fi
\ifnum\i>1\node[fill=green!50!black] (B) at (-1,-0.5) {$B$};\fi
\ifnum\i>10\node[fill=yellow!75!black] (C) at (6,-0.5) {$C$};\fi
\ifnum\i>5\node (I) at (3,-0.5) {$\displaystyle \int$};\fi
\end{scope}

\begin{scope}[mySimpleArrow={blue}{cyan}]
\ifnum\i>0\path[->] (-2.5,-0.5) node[above]{$u$} -- ($(-1.5,-0.5)-(0.5pt,0)$);\fi
\ifnum\i>2\path[->] ($(-0.5,-0.5)+(0.5pt,0)$) -- ($(0.5,-0.5)-(0.5pt,0)$);\fi
\ifnum\i>4\path[->] ($(1.5,-0.5)+(0.5pt,0)$) -- ($(2.5,-0.5)-(0.5pt,0)$) node[midway, above] {$\dot{x}$};\fi

\ifnum\i>6\path[->] ($(3.5,-0.5)+(0.5pt,0)$) -- ($(4.5,-0.5)-(0.5pt,0)$) coordinate(x) node[above]{$x$} -- ($(5.5,-0.5)-(0.5pt,0)$);\fi
\ifnum\i>7\path (4.5,-0.5) |- ($(3.5,-2)+(0.5pt,0)$);\fi
\ifnum\i>9\path[->] ($(2.5,-2)-(0.5pt,0)$) -| ($(1,-1)-(0,0.5pt)$);\fi

\ifnum\i>11\path[->] ($(6.5,-0.5)+(0.5pt,0)$) -- ++(1.5,0) node[above]{$y$};\fi
\end{scope}
\end{tikzpicture}
}
\end{animateinline}
\end{document}

And the animation result:

• I really liked the structure \ifnum\i>step<code>\fi.
– FHZ
Commented Apr 29, 2022 at 16:12

One more suggestion:

• replicate animation as is done in MWE in question
• simplified styles of tikzpicture elements
• shorter and simpler code
\documentclass[border=2mm]{standalone}
\usepackage{amsmath,tikz,animate}
\usetikzlibrary{fit,
positioning,
quotes}

\newcommand\ppbb{path picture bounding box}
\tikzset{
arr/.style = {color=#1, very thick, -latex},
box/.style = {draw, very thick, fill=#1!30,
minimum size=16mm, font=\Huge},
FIT/.style = {draw=red, thick, densely dashed,
fit=#1, inner sep=3mm, node contents={}},
sum/.style = {circle, draw, very thick, minimum size=10mm,
path picture={
\draw[thick] (\ppbb.north west) -- (\ppbb.south east)
(\ppbb.south west) -- (\ppbb.north east);
},
node contents={} },
every node/.append style = {inner sep=2pt},
}
\begin{document}
\begin{animateinline}[loop, controls]{2}
\multiframe{9}{ii=0+1}{
\begin{tikzpicture}[
node distance = 3mm and 12mm
]
%
\pgfmathsetmacro{\jj}{int(\ii-1)}
\path (-7,3.3) rectangle ++(14,-6.6);
%
\ifnum\ii > 1
\path (-7,3.3) rectangle ++(14,-6.6)
node[above left=6mm and 12mm,
font=\huge, text=blue] {Step \jj};
%
\node (int) [box=white] {$\int$};
\draw [arr=teal] (int.east) to["$x$"] ++ (1.2,0) coordinate (X);
\path (int) --  coordinate (x) (X);
%
\node (S1) [sum, left=of int];
\draw [arr=orange] (S1) to["$\dot{x}$"] (int);
\fi
\ifnum\ii > 2
\node (A)   [box=orange, below=of int] {$A$};
\draw [arr=teal] (x) |- (A);
\fi
\ifnum\ii > 3
\draw [arr=cyan] (A) -| (S1.south) node[above] {$+$};
\fi
\ifnum\ii > 4
\node (B)   [box=red, left=of S1] {$B$};
\path (B.west) --  coordinate (d) ++ (-1,0)  coordinate (in);
\draw [arr=teal] (in) to[pos=0.2,"$u$"] (B);
\draw [arr=red] (B)  -- (S1.west)  node[right] {$+$};
\fi
\ifnum\ii > 5
\node (C)   [box=olive, right=of int]   {$C$};
\node (S2)  [sum, right=of C];
\draw [arr=olive]  (C)  to["$y$"] (S2);
\draw [arr=violet] (S2.east)  to["$y$"] ++ (1,0);
\fi
\ifnum\ii > 6
\node (D)   [box=cyan, above=of int] {$D$};
\draw [arr=teal] (d) |- (D);
\draw [arr=teal] (D) -| (S2.north) node[below] {$+$};
\fi
\ifnum\ii > 7
\node [FIT=(B) (D) (S2) (A),
label={[anchor=south west, inner sep=6mm]%
south west:\begin{aligned} \dot{x} & = Ax + Bu\\ y & = Cx + Du \end{aligned}}];
\fi
\end{tikzpicture}
}
\end{animateinline}
\end{document}

Edit: final step.

Addendum (off-topic): I would change order of "uncovering" of elements of your control scheme showed in MWE 1 in your question. This require a wee bit longer image code.

\documentclass[border=3.131592]{standalone}
\usepackage{amsmath,tikz,animate}
\usetikzlibrary{arrows.meta,
fit,
positioning,
quotes}

\newcommand\ppbb{path picture bounding box}
\tikzset{
arr/.style = {draw=#1, very thick, -Straight Barb},
box/.style = {draw=#1, very thick, fill=#1!30,
minimum size=13mm, font=\Huge},
FIT/.style = {draw=red, thick, densely dashed, semitransparent,
fit=#1, inner sep=3mm, node contents={}},
sum/.style = {circle, draw, very thick, fill=#1, minimum size=10mm,
path picture={
\draw[thick] (\ppbb.north west) -- (\ppbb.south east)
(\ppbb.south west) -- (\ppbb.north east);
},
node contents={} },
every node/.append style = {inner sep=2pt},
}
\begin{document}
\begin{animateinline}[loop, controls]{2}
\multiframe{8}{ii=0+1}{
\begin{tikzpicture}[
node distance = 5mm and 15mm
]
%
\pgfmathsetmacro{\jj}{int(\ii-1)}
\path (-5.5,3) rectangle ++(15.5,-6);
%
\ifnum\ii > 1
\path (-5.5,3) rectangle ++(15.5,-6)
node[above left, text=blue] {Step \jj};
%
\coordinate (Ia);
\node (I)   [box=red, right=of Ia] {$\int$};
\coordinate[right=of I] (Ib);
\path[arr=red] (Ia) to["$\dot{x}$"] (I);
\path[arr=red] (I)  to[name=d, "$x$"]       (Ib);
\path (I) --  coordinate (a) (Ib);
\fi
\ifnum\ii > 2
\node (S1)  [sum=orange, left=of I];
\coordinate[left=of S1] (Bb);
\node (A)  [box=orange, below=of I] {$A$};
\path [arr=orange] (Bb) to["$v$"] (S1.west) node[right] {$+$};
\path [arr=orange] (a) |- (A);
\path [arr=orange] (A) -| (S1.south)
node[above] {$+$}
node[pos=0.75,right] {$Ax$};
\fi
\ifnum\ii > 3
\node (B)   [box=teal, left=of S1] {$B$};
\coordinate[left=of B] (in);
\path [arr=teal] (in) to[pos=0.2,"$u$"] (B);
\path (in) --  coordinate (d) (B);
\path (B)   to["$v=Bu$" '] (S1);
\fi
\ifnum\ii > 4
\node (C)   [box=olive, right=of I]   {$C$};
\coordinate[right=of C] (c);
\draw [arr=olive] (C)  to["$Cx$"] (c);
\fi
\ifnum\ii > 5
\node (S2)  [sum=cyan, right=of C];
\coordinate[right=of S2] (out);
\path [arr=olive] (S2)  to["$y$"] (out);
\path (I) -- (S2.west) node[right] {$+$};
\node (D)   [box=cyan, above=of I] {$D$};
\path [arr=cyan] (d) |- (D);
\path [arr=cyan] (D) -| (S2.north)
node[below] {$+$}
node[pos=0.75,right] {$Du$};
\fi
\ifnum\ii > 6
\node [FIT=(B) (I) (C) (A),
label={[anchor=south west, inner sep=3mm]%
south west:\begin{aligned} \dot{x} & = Ax + Bu\\ y & = Cx \end{aligned}}];
\fi
\end{tikzpicture}
}
\end{animateinline}
\end{document}

On the same way you can draw second scheme showed in MWE 2:

\documentclass[border=3.131592]{standalone}
\usepackage{amsmath,tikz,animate}
\usetikzlibrary{arrows.meta,
fit,
positioning,
quotes}

\newcommand\ppbb{path picture bounding box}
\tikzset{
arr/.style = {draw=#1, very thick, -Straight Barb},
box/.style = {draw=#1, very thick, fill=#1!30,
minimum size=13mm, font=\Huge},
FIT/.style = {draw=red, thick, densely dashed, semitransparent,
fit=#1, inner sep=3mm, node contents={}},
sum/.style = {circle, draw, very thick, fill=#1, minimum size=10mm,
path picture={
\draw[thick] (\ppbb.north west) -- (\ppbb.south east)
(\ppbb.south west) -- (\ppbb.north east);
},
node contents={} },
every node/.append style = {inner sep=2pt},
}
\begin{document}
\begin{animateinline}[loop, controls]{2}
\multiframe{6}{ii=0+1}{
\begin{tikzpicture}[
node distance = 5mm and 15mm
]
\draw (-5.5,1) rectangle ++(12.75,-3.75);
%
\ifnum\ii > 1
\coordinate (Ia);
\node (I)   [box=red, right=of Ia] {$\int$};
\coordinate[right=of I] (Ib);
\path[arr=red] (Ia) to["$\dot{x}$"] (I);
\path[arr=red] (I)  to[name=d, "$x$"]       (Ib);
\path (I) --  coordinate (a) (Ib);
\fi
\ifnum\ii > 2
\node (S1)  [sum=orange, left=of I];
\coordinate[left=of S1] (Bb);
\node (A)  [box=orange, below=of I] {$A$};
\path [arr=orange] (Bb) to["$v$"] (S1.west) node[right] {$+$};
\path [arr=orange] (a) |- (A);
\path [arr=orange] (A) -| (S1.south)
node[above] {$+$}
node[pos=0.75,right] {$Ax$};
\fi
\ifnum\ii > 3
\node (B)   [box=teal, left=of S1] {$B$};
\coordinate[left=of B] (in);
\path [arr=teal] (in) to[pos=0.2,"$u$"] (B);
\path (in) --  coordinate (d) (B);
\path (B)   to["$v=Bu$" '] (S1);
\fi
\ifnum\ii > 4
\node (C)   [box=olive, right=of I]   {$C$};
\coordinate[right=of C] (c);
\draw [arr=olive] (C)  to["$Cx$"] (c);
\node[below=of B]  {\begin{aligned} \dot{x} & = Ax + Bu\\ y & = Cx \end{aligned}};
\fi
\end{tikzpicture}
}
\end{animateinline}
\end{document}

last step gives:

• I really appreciate the simplified styles, i will definitely start using some, or at least save them as variations. I noticed you redesigned the diagram to fit the presentation order. I liked the structure \node (name) [box=<>, below=of <>].
– FHZ
Commented Apr 29, 2022 at 16:24