1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
|
\TFRGB{Utilisation du module \og pgffor \fg chargé automatiquement avec TikZ }{Package used : \og pgffor \fg (automatically loaded with TikZ) }
\SbSSCT{Répétition à 1 variable}{One variable repetition}
\begin{tabular}{|c|} \hline
\tikz \foreach \x in {1,...,10} \fill[blue](\x,0) circle (0.4cm);
\\ \hline
\BS{tikz} \BSS{foreach} \BSR{x} in \AC{1,...,10} \BS{fill}[blue](\BSR{x},0) circle (0.4cm);
\\ \hline
Variable \BSR{x} : position en X
\\ \hline
\end{tabular}
\SbSSCT{Répétition à 2 variables}{Two variables repetition}
\begin{tabular}{|c|} \hline
\TFRGB{Liste de variables numériques}{Numerical variables}
\\ \hline
\tikz \foreach \pos/\y in {1/10,2/20,3/30,4/40,5/50,6/60,7/70,8/80,9/90,10/100} \fill[color=blue!\y](\pos,0) circle (0.5cm);
\\ \hline
\BS{tikz} \BS{foreach} \BSR{pos}/\BSB{y} in \AC{1/10,2/20,3/30,4/40,5/50,6/60,7/70,8/80,9/90,10/100} \\ \BS{fill}[color=blue!\BSB{y}](\BSR{pos},0) circle (0.5cm);
\\ \hline
Variable \BSR{pos} : position en X \hspace{1cm} Variable \BSB{y} : couleur
\\ \hline
\end{tabular}
\bigskip
\begin{tabular}{|c|} \hline
\TFRGB{Liste de variables mixtes}{Composite variables}
\\ \hline
\tikz \foreach \x/\col in {1/red,3/green,5/magenta,7/blue} \shade[ball color=\col](\x,0) circle (1);
\\ \hline
\BS{tikz} \BS{foreach} \BSR{x}/\BSB{col} in {1/red,3/green,5/magenta,7/blue} \BS{shade}[ball color=\BSB{col}](\BSR{x},0) circle (1);
\\ \hline
Variable \BSR{x} : position en X \hspace{1cm} Variable \BSB{col} : couleur
\\ \hline
\end{tabular}
\bigskip
\begin{tabular}{|c|} \hline
\TFRGB{Liste de variables avec un pas}{Variables with a step}
\\ \hline
\begin{tikzpicture}
\foreach \x in {1,2,...,4,7,8,...,10}
\foreach \y in {1,...,3}
{ \draw (\x,\y) +(-.5,-.5) rectangle ++(.5,.5);
\draw (\x,\y) node{\x,\y};
}
\end{tikzpicture}
\\ \hline
\parbox{12cm}{
\BS{begin}\AC{tikzpicture}\\
\BS{foreach} \BSR{x} in\AC{1,2,...,4,7,8,...,10} \\
\BS{foreach} \BSB{y} in \AC{1,...,3} \\
\AC{ \BS{draw} (\BSR{x},\BSB{y}) +(-.5,-.5) rectangle ++(.5,.5);
\BS{draw} (\BSR{x},\BSB{y}) node{\BSR{x},\BSB{y}}; }\\
\BS{end}\AC{tikzpicture} \\
}
\\ \hline
Variable \BSR{x} : position en X \hspace{1cm} Variable \BSR{y} : position en Y
\\ \hline
\end{tabular}
\bigskip
\begin{tabular}{|l|l|} \hline
\multicolumn{2}{|c|}{ \TFRGB{Exemples de liste}{List example }}
\\ \hline
\foreach \x in {1,...,6} {\x, }
&
\BS{foreach} \BSR{x} in \AC{1,...,6} \AC{\BSR{x}, }
\\ \hline
\foreach \x in {1,3,...,11} {\x, }
&
\BS{foreach} \BSR{x} in \AC{1,3,...,11} \AC{\BSR{x}, }
\\ \hline
\foreach \x in {Z,X,...,M} {\x, }
&
\BS{foreach} \BSR{x} in \AC{Z,X,...,M} \AC{\BSR{x}, }
\\ \hline
\foreach \x in {2^1,2^...,2^7} {$\x$, }
&
\BS{foreach} \BSR{x} in \AC{2\^{}1,2\^{}...,2\^{}7} \AC{\BSR{x}, }
\\ \hline
\foreach \x in {0cm,0.5cm,...cm,3cm} {$\x$, }
&
\BS{foreach} \BSR{x} in \AC{0cm,0.5cm,...cm,3cm} \AC{\BSR{x}, }
\\ \hline
\foreach \x in {A_1,..._1,H_1} {$\x$, }
&
\BS{foreach} \BSR{x} in \AC{A\_1,...\_1,H\_1} \AC{\BSR{x}, }
\\ \hline
\end{tabular}
\bigskip
\begin{tabular}{|c|} \hline
\TFRGB{Variables numériques avec opération}{Calculation on variables}
\\ \hline
\begin{tikzpicture}
\foreach \x in {0,20,...,360}{ \filldraw[red] (0,0) .. controls (\x+10:1) .. (\x:3) .. controls (\x-10:1) .. (0,0);}
\foreach \x in {10,30,...,370}{ \filldraw[blue] (0,0) .. controls (\x+10:1) .. (\x:3) .. controls (\x-10:1) .. (0,0);}
\end{tikzpicture}
\\ \hline
\parbox{12cm}{
\BS{begin}\AC{tikzpicture}\\
\BS{foreach} \BSR{x} in {0,20,...,360}\AC{ \BS{filldraw}[red] (0,0) .. controls (\BSR{x}+10:1) .. (\BSR{x}:1) .. controls (\BSR{x}-10:1) .. (0,0);} \\
\BS{foreach} \BSR{x} in {10,30,...,370}\AC{ \BS{filldraw}[blue] (0,0) .. controls (\BSR{x}+10:3) .. (\BSR{x}:3) .. controls (\BSR{x}-10:3) .. (0,0);} \\
\BS{end}\AC{tikzpicture} \\
}
\\ \hline
Variable \BSR{x} : angle
\\ \hline
\end{tabular}
\SbSSCT{Répétition à 2 variables - boucles imbriquées}{Nested loops}
\begin{tabular}{|c|c|} \hline
\multicolumn{2}{|c|}{\TFRGB{Ordre des boucles imbriquées}{Order of the nested loops }}
\\ \hline
\begin{tikzpicture}[blue]
\draw (0,0)
\foreach \x in {1,2,3}
{\foreach \y in {0,1,2}
{-- (\x,\y) node{X}}};
\end{tikzpicture}
&
\begin{tikzpicture}[blue]
\draw (0,0)
\foreach \y in {0,1,2}
\foreach \x in {1,2,3}
{-- (\x,\y) node{X}};
\end{tikzpicture}
\\ \hline
\parbox{5cm}{
\BS{begin}\AC{tikzpicture} \\
\BS{draw} (0,0) \\
\BS{foreach} \BSR{x} in \AC{1,2,3} \\
\BS{foreach} \BSB{y} in \AC{0,1,2} \\
\AC{-- (\BSR{x},\BSB{y}) node\AC{X}};\\
\BS{end}\AC{tikzpicture} \\ }
&
\parbox{5cm}{
\BS{begin}\AC{tikzpicture} \\
\BS{draw} (0,0) \\
\BS{foreach} \BSB{y} in \AC{0,1,2}\\
\BS{foreach} \BSR{x} in \AC{1,2,3}\\
\AC{-- (\BSR{x},\BSB{y}) node\AC{X}};\\
\BS{end}\AC{tikzpicture} \\ }
\\ \hline
\end{tabular}
|