1 \documentclass[12pt
]{article
}
2 \usepackage[utf8
]{inputenc}
3 \usepackage[T1]{fontenc}
4 \usepackage[a4paper,margin=
2cm,nohead,includefoot
]{geometry
}
6 \usepackage[scaled=
0.875]{helvet
}
8 \usepackage[frenchb
]{babel
}
11 \graphicspath{{figures/
}}
12 \DeclareGraphicsRule{*
}{mps
}{*
}{}
16 \usepackage{listingsutf8
}
17 \usepackage{filecontents
}
18 \lstset{language=MetaPost,inputencoding=utf8,basicstyle=
\sffamily}
19 \usepackage[tikz
]{bclogo
}
20 %\renewcommand\bcStyleTitre[1]{}
21 \title{\includegraphics[scale=
0.05]{Scratch_cat.png
}\kern0.05
\linewidth Scratch et
\MP\kern0.05
\linewidth\includegraphics{Carre
.1}}
25 \url{chrpoulain@gmail.com
}\\
32 Comment utiliser
\MP\ pour produire des algorithmes
\og papier
\fg\ avec les conventions de Scratch.
35 \setcounter{tocdepth}{1}
38 Avec les nouveaux programmes
2016 du Cycle
4 (Classes de
5\ieme\ à
3\ieme\ de collège) est apparu l'enseignement de l'algorithmique et l'utilisation de Scratch. Développé par le laboratoire Média du MIT, il permet de mettre en
\oe uvre des algorithmes sous forme
{\em ludique
}. Sans rentrer dans un débat
\og pour ou contre
\fg, son emploi doit donc être enseigné aux élèves aux travers de différentes activités : questions
{\em flash
}\footnote{Sans aucun lien avec le langage informatique. Il s'agit de questions rapides posées en début de séance.
}, questions de compréhension, modification, correction d'algorithmes
\ldots\ Il fallait donc trouver une solution me permettant de proposer des algorithmes Scratch dans mes devoirs.
\par La première solution envisagée a été, bien évidemment, la capture d'écran. Simple, facile, rapide
\ldots\ ses avantages sont nombreux. Cependant, la qualité d'impression est parfois
\og moyenne
\fg\ldots
39 \
\Soucieux de proposer quelque chose de plus
{\em cohérent
} avec le
\og monde
\fg\
\LaTeX, je me suis lancé dans la création de
{\sffamily mp-scratch
} avec pour objectif principal de proposer une syntaxe et une présentation très proche de celles utilisées par Scratch.
42 \includegraphics[scale=
0.85]{Scratch1.png
}\kern0.05
\linewidth\includegraphics{Algo1.1
}
43 \caption{Algorithme de création d'un carré - Versions Scratch et
\MP\protect\footnotemark}
46 \footnotetext{Ce premier algorithme me permet de remercier Maxime Chupin et son package
{\sffamily bclogo
} : le drapeau vert a été créé à partir des sources de son package et notamment la construction, en
\MP, de ses drapeaux.
}
47 \section{Installation
}
48 {\sffamily mp-scratch
} est indépendant des autres packages personnels déjà produits tels
\lstinline!geometriesyr16!,
\lstinline!mp-geo! ou
\lstinline!mp-solid!.
49 \
\Au travers d'un dépôt
\lstinline!git!
\footnote{Tous les contributeurs sont donc les bienvenus pour développer le package.
}, on trouvera l'archive à l'adresse
51 \url{http://melusine.eu.org/syracuse/G/mp-scratch/
}
53 et l'ensemble des fichiers sera à placer correctement dans une arborescence
\TeX\footnote{Arborescence locale de préférence, par exemple dans
{\sffamily /home/christophe/texmf/metapost/
} sous Linux.
}.
54 \
\Pour l'utilisation, il sera nécessaire de veiller :
56 \item à installer, si ce n'est pas fait, la fonte
{\sffamily Carlito
}\footnote{\url{http://www.tug.dk/FontCatalogue/carlito/
} pour un exemple. Le choix reste personnalisable évidemment mais Thierry Pasquier, à juste titre, m'a préconisé d'utiliser une fonte sans serif.
};
57 \item à modifier, dans le fichier
{\sffamily LATEXScratch.mp
}, la ligne
60 \lstinline! write "
\graphicspath{{/home/cp/texmf/metapost/Scratch/
}}" to "mptextmp.mp";!
63 pour indiquer le chemin correspondant à votre installation.
68 \begin{minipage
}{0.4\linewidth}
69 \includegraphics{Algo1.1
}
72 \begin{minipage
}{0.4\linewidth}
74 \begin{lstlisting
}[firstnumber=
1,frame=tb
]
82 draw FinBlocRepeter1(
10);
87 \caption{Un carré - Code et résultat sous
\MP}
91 Reprenons l'exemple de l'algorithme du carré pour faire les premières constatations suivantes :
93 \item la syntaxe est très proche du vocabulaire utilisé par Scratch; donc très peu de nouvelles commandes à apprendre
\ldots
94 \item les couleurs
\footnote{Cela reste, bien évidemment, paramétrable. Les paramètres disponibles pour personnaliser les couleurs sont
\lstinline!colMouv!,
\lstinline!colAp!,
\lstinline!colSon!,
\lstinline!colStylo!,
\lstinline!colEvenements!,
\lstinline!colControle!,
\lstinline!colCapteur!,
\lstinline!colBloc!,
\lstinline!colVar!,
\lstinline!colList!.
} sont celles utilisées par Scratch
\footnote{Une nouvelle fois, merci à Maxime Chupin pour m'avoir fait découvrir l'utilitaire
\lstinline!gcolor2! sous Linux
};
95 \item le bloc
{\sffamily Répéter
} est particulier car il nécessite l'ajout
{\em manuel
} d'un nombre (ou chiffre)
\footnote{{\sffamily Repeter2
},
{\sffamily Repeter5
}\ldots} qui permettra à
\MP\ de faire la liaison correcte lors de la présence de multiples blocs
{\sffamily Répéter
} comme le montre l'exemple ci-dessous.
99 \begin{minipage
}{0.45\linewidth}
100 \includegraphics{Algo2.1
}
103 \begin{minipage
}{0.35\linewidth}
105 \begin{lstlisting
}[firstnumber=
1,frame=tb
]
114 draw FinBlocRepeter1(
10);
116 draw FinBlocRepeter2(
10);
121 \caption{Un carré se déplace - Code et résultat sous
\MP}
125 \begin{bclogo
}[arrondi=
0.1,logo=
\bcattention,noborder=true,cadreTitre=false,barre=none
]{}
126 Pour les codes
\MP\ suivants, on omettra volontairement
\lstinline!input mp-scratch! et
\lstinline!end!.
\footnotemark
128 \footnotetext{Chacun aura reconnu le package
\lstinline!bclogo! de Maxime Chupin.
}
129 \subsection{Commandes Scratch
}
131 \item[Groupe
{\sffamily Mouvement
}]\hfil\newline
133 \item[\textbullet]\lstinline!draw Avancer(
10);!
134 \par\hfill\includegraphics{CommandeMouvement
.1}
135 \item[\textbullet]\lstinline!draw Tournerd(
90);!
136 \par\hfill\includegraphics{CommandeMouvement
.2}
137 \item[\textbullet]\lstinline!draw Tournerg(
90)!
138 \par\hfill\includegraphics{CommandeMouvement
.3}
139 \item[\textbullet]\lstinline!draw Orienter(
90);!
140 \par\hfill\includegraphics{CommandeMouvement
.4}
141 \item[\textbullet]\lstinline!draw Orienterdirection("pointeur de souris");!
142 \par\hfill\includegraphics{CommandeMouvement
.5}
143 \item[\textbullet]\lstinline!draw Aller(
50,
100);!
144 \par\hfill\includegraphics{CommandeMouvement
.6}
145 \item[\textbullet]\lstinline!draw Allera("pointeur de souris");!
146 \par\hfill\includegraphics{CommandeMouvement
.7}
147 \item[\textbullet]\lstinline!draw Glisser(
2,
50,
100);!
148 \par\hfill\includegraphics{CommandeMouvement
.8}
149 \item[\textbullet]\lstinline!draw Ajouter(
10,"x");!
150 \par\hfill\includegraphics{CommandeMouvement
.9}
151 \item[\textbullet]\lstinline!draw Mettre(
10,"x");!
152 \par\hfill\includegraphics{CommandeMouvement
.10}
153 \item[\textbullet]\lstinline!draw Ajouter(
50,"y");!
154 \par\hfill\includegraphics{CommandeMouvement
.11}
155 \item[\textbullet]\lstinline!draw Mettre(
10,"y");!
156 \par\hfill\includegraphics{CommandeMouvement
.12}
157 \item[\textbullet]\lstinline!draw Rebondir;!
158 \par\hfill\includegraphics{CommandeMouvement
.13}
159 \item[\textbullet]\lstinline!draw FixerSensRotation("position \`a gauche ou \`a droite"';!
160 \par\hfill\includegraphics{CommandeMouvement
.14}
162 Les
\og opérateurs
\footnote{Je nomme
\og opérateurs
\fg\ les variables ou commandes Scratch pouvant s'inclure dans les blocs-commande. Je me demande si je suis assez clair
\ldots}\fg\
163 \
[\includegraphics{CommandeMouvement
.18}\kern0.1
\linewidth\includegraphics{CommandeMouvement
.19}\kern0.1
\linewidth\includegraphics{CommandeMouvement
.20}\
]
164 s'obtiennent avec la commande
\LaTeX\footnote{Oui, une commande
\LaTeX. Cela signifie donc que cette commande sera passée comme un élément de type
{\sffamily string
} de
\MP.
} \lstinline!
\opMouv{}! comme le montrent les exemples ci-dessous :
166 \item[\textbullet]\lstinline!draw Avancer("
\opOp{$
\opMouv{abscisse x
}\bm{+
}\opSimple{10}$
}");!
167 \par\hfill\includegraphics{CommandeMouvement
.15}
168 \item[\textbullet]\lstinline!draw Mettre("
\opMouv{abscisse x
}","y");!
169 \par\hfill\includegraphics{CommandeMouvement
.16}
170 \item[\textbullet]\lstinline!draw Ajouter("
\opMouv{direction
}","y");!
171 \par\hfill\includegraphics{CommandeMouvement
.17}
174 \item[Groupe
{\sffamily Apparence
}]\hfil\newline
176 \item[\textbullet]\lstinline!draw DireT("Hello",
2);!
177 \par\hfill\includegraphics{CommandeApparence
.1}
178 \item[\textbullet]\lstinline!draw Dire("Hello");!
179 \par\hfill\includegraphics{CommandeApparence
.2}
180 \item[\textbullet]\lstinline!draw PenserT("Hmm...",
2);!
181 \par\hfill\includegraphics{CommandeApparence
.3}
182 \item[\textbullet]\lstinline!draw Penser("Hmm...");!
183 \par\hfill\includegraphics{CommandeApparence
.4}
184 \item[\textbullet]\lstinline!draw Montrer;!
185 \par\hfill\includegraphics{CommandeApparence
.5}
186 \item[\textbullet]\lstinline!draw Cacher;!
187 \par\hfill\includegraphics{CommandeApparence
.6}
188 \item[\textbullet]\lstinline!draw Basculer("
\opAp{costume2
}");!
189 \par\hfill\includegraphics{CommandeApparence
.7}
190 \item[\textbullet]\lstinline!draw CostumeSuivant;!
191 \par\hfill\includegraphics{CommandeApparence
.8}
192 \item[\textbullet]\lstinline!draw BasculerAR("
\opAp{arriere-plan2
}");!
193 \par\hfill\includegraphics{CommandeApparence
.9}
194 \item[\textbullet]\lstinline!draw AjouterEffet("
\opAp{couleur
}",
10);!
195 \par\hfill\includegraphics{CommandeApparence
.10}
196 \item[\textbullet]\lstinline!draw MettreEffet("
\opAp{couleur
}",
10);!
197 \par\hfill\includegraphics{CommandeApparence
.11}
198 \item[\textbullet]\lstinline!draw AnnulerEffet;!
199 \par\hfill\includegraphics{CommandeApparence
.12}
200 \item[\textbullet]\lstinline!draw AjouterTaille(
10);!
201 \par\hfill\includegraphics{CommandeApparence
.13}
202 \item[\textbullet]\lstinline!draw MettreA("
\opOp{$
\opSimple{10}\bm{+
}\opSimple{5}$
}");!
203 \par\hfill\includegraphics{CommandeApparence
.14}
204 \item[\textbullet]\lstinline!draw AllerPPlan;!
205 \par\hfill\includegraphics{CommandeApparence
.15}
206 \item[\textbullet]\lstinline!draw DeplacerAP("
\opOp{$
\opMouv{abscisse x
}\bm{+
}\opSimple{10}$
}");!
207 \par\hfill\includegraphics{CommandeApparence
.16}
209 \par\vspace*
{2em
}\par Les
\og opérateurs
\fg\
210 \
[\includegraphics{CommandeApparence
.17}\kern0.1
\linewidth\includegraphics{CommandeApparence
.18}\kern0.1
\linewidth\includegraphics{CommandeApparence
.19}\
]
211 s'obtiennent avec la commande
\LaTeX\
\lstinline!
\opAp{}!.
212 \par\vspace*
{2em
}\par
213 \item[Groupe
{\sffamily Son
}]\hfil\newline
215 \item[\textbullet]\lstinline!draw Jouer("miaou");!
216 \par\hfill\includegraphics{CommandeSon
.1}
217 \item[\textbullet]\lstinline!draw JouerT("miaou");!
218 \par\hfill\includegraphics{CommandeSon
.2}
219 \item[\textbullet]\lstinline!draw ArreterSon;!
220 \par\hfill\includegraphics{CommandeSon
.3}
221 \item[\textbullet]\lstinline!draw Tambour(
2,
0.25);!
222 \par\hfill\includegraphics{CommandeSon
.4}
223 \item[\textbullet]\lstinline!draw Pause(
0.25);!
224 \par\hfill\includegraphics{CommandeSon
.5}
225 \item[\textbullet]\lstinline!draw JouerNote(
50,
0.25);!
226 \par\hfill\includegraphics{CommandeSon
.6}
227 \item[\textbullet]\lstinline!draw ChoisirInstrument(
17);!
228 \par\hfill\includegraphics{CommandeSon
.7}
229 \item[\textbullet]\lstinline!draw AjouterVol(-
10);!
230 \par\hfill\includegraphics{CommandeSon
.8}
231 \item[\textbullet]\lstinline!draw MettreVol(
15);!
232 \par\hfill\includegraphics{CommandeSon
.9}
233 \item[\textbullet]\lstinline!draw AjouterTempo(
20);!
234 \par\hfill\includegraphics{CommandeSon
.10}
235 \item[\textbullet]\lstinline!draw MettreTempo(
15);!
236 \par\hfill\includegraphics{CommandeSon
.11}
238 Les
\og opérateurs
\fg
239 \
[\includegraphics{CommandeSon
.12}\kern0.1
\linewidth\includegraphics{CommandeSon
.13}\
]
240 s'obtiennent par la commande
\LaTeX\
\lstinline!
\opSon{}!.
241 \par\vspace*
{2em
}\par
242 \item[Groupe
{\sffamily Stylo
}]\hfil\newline
244 \item[\textbullet]\lstinline!draw Effacer;!
245 \par\hfill\includegraphics{CommandeStylo
.1}
246 \item[\textbullet]\lstinline!draw Estampiller;!
247 \par\hfill\includegraphics{CommandeStylo
.2}
248 \item[\textbullet]\lstinline!draw PoserStylo;!
249 \par\hfill\includegraphics{CommandeStylo
.3}
250 \item[\textbullet]\lstinline!draw ReleverStylo;!
251 \par\hfill\includegraphics{CommandeStylo
.4}
252 \item[\textbullet]\lstinline!draw MettreCouleur("Magenta",
1,
0,
1);!
\footnote{La couleur est définie par son triplet
{\sffamily rgb
}. Le nom de la couleur est libre mais ne doit pas rentrer en conflit avec les couleurs déjà définies dans le sous-package
{\sffamily LATEXScratch.mp
}.
}
253 \par\hfill\includegraphics{CommandeStylo
.5}
254 \item[\textbullet]\lstinline!draw AjouterCS("
\opOp{$
\opSimple{15}\bm{+
}\opSimple{10}$
}");!
255 \par\hfill\includegraphics{CommandeStylo
.6}
256 \item[\textbullet]\lstinline!draw MettreCS(
25);!
257 \par\hfill\includegraphics{CommandeStylo
.7}
258 \item[\textbullet]\lstinline!draw AjouterIS("
\opOp{$
\opSimple{25}\bm{-
}\opSimple{10}$
}");!
259 \par\hfill\includegraphics{CommandeStylo
.8}
260 \item[\textbullet]\lstinline!draw MettreIS(
15);!
261 \par\hfill\includegraphics{CommandeStylo
.9}
262 \item[\textbullet]\lstinline!draw AjouterTS(
12);!
263 \par\hfill\includegraphics{CommandeStylo
.10}
264 \item[\textbullet]\lstinline!draw MettreTS("
\opOp{$
\opSimple{15}\bm{\times}\opSimple{10}$
}");!
265 \par\hfill\includegraphics{CommandeStylo
.11}
268 \item[Groupe
{\sffamily Données
}]\hfil\newline
270 \item[\textbullet]\lstinline!draw MettreVar("pi",
0);!
271 \par\hfill\includegraphics{CommandeVariable
.1}
272 \item[\textbullet]\lstinline!draw AjouterVar("pi","
\opOp{$
\opSimple{15}\bm{+
}\opSimple{10}$
}");!
273 \par\hfill\includegraphics{CommandeVariable
.2}
274 \item[\textbullet]\lstinline!draw MontrerVar("pi");!
275 \par\hfill\includegraphics{CommandeVariable
.3}
276 \item[\textbullet]\lstinline!draw CacherVar("pi");!
277 \par\hfill\includegraphics{CommandeVariable
.4}
278 \item[\textbullet]\lstinline!draw AjouterList("
\opSimple{\LaTeX}","Listepi");!
279 \par\hfill\includegraphics{CommandeVariable
.5}
280 \item[\textbullet]\lstinline!draw SupprimerList("
\opSimple{\LaTeX}","Listepi");!
281 \par\hfill\includegraphics{CommandeVariable
.6}
282 \item[\textbullet]\lstinline!draw InsererList("
\opSimple{\MP}",
1,"Listepi");!
283 \par\hfill\includegraphics{CommandeVariable
.7}
284 \item[\textbullet]\lstinline!draw RemplacerList(
3,"Listepi","
\opOp{$
\opSimple{4}\bm{+
}\opSimple{5}$
}");!
285 \par\hfill\includegraphics{CommandeVariable
.8}
286 \item[\textbullet]\lstinline!draw MontrerList("Listepi");!
287 \par\hfill\includegraphics{CommandeVariable
.9}
288 \item[\textbullet]\lstinline!draw CacherList("Listepi");!
289 \par\hfill\includegraphics{CommandeVariable
.10}
291 \par\vspace*
{2em
}\par Les
\og opérateurs
\fg
293 \begin{minipage
}{0.8\linewidth}
294 \includegraphics{CommandeVariable
.11}\hfill\includegraphics{CommandeVariable
.12}\hfill \includegraphics{CommandeVariable
.13}\par
295 \includegraphics{CommandeVariable
.14}\hfill \includegraphics{CommandeVariable
.15}
298 s'obtiennent par les commandes
\LaTeX\
\lstinline!
\opVar{}!,
\lstinline!
\opList{}! et
\lstinline!
\opSousList{}!.
301 \includegraphics{CommandeVariable
.15}
302 % \begin{minipage}{0.6\linewidth}
303 \begin{lstlisting
}[frame=tb
]
304 label(LATEX("
\opList{\opSousList{Pythagore
}
305 contient
\opSimple{(
3;
4;
5)
} ?
}"),(
0,
0));
309 \par\vspace*
{2em
}\par
310 \item[Groupe
{\sffamily \'Evènement
}]\hfil\newline
312 \item[\textbullet]\lstinline!draw Drapeau;!
313 \par\hfill\includegraphics{CommandeEvenements
.1}
314 \item[\textbullet]\lstinline!draw QPresse("espace");!
315 \par\hfill\includegraphics{CommandeEvenements
.2}
316 \item[\textbullet]\lstinline!draw QLutinPresse;!
317 \par\hfill\includegraphics{CommandeEvenements
.3}
318 \item[\textbullet]\lstinline!draw QBasculeAR("arriere-plan1");!
319 \par\hfill\includegraphics{CommandeEvenements
.4}
320 \item[\textbullet]\lstinline!draw QVolumeSup("Volume sonore",
10);!
321 \par\hfill\includegraphics{CommandeEvenements
.5}
322 \item[\textbullet]\lstinline!draw QRecevoirMessage("message1");!
323 \par\hfill\includegraphics{CommandeEvenements
.6}
324 \item[\textbullet]\lstinline!draw EnvoyerMessage("message1");!
325 \par\hfill\includegraphics{CommandeEvenements
.7}
326 \item[\textbullet]\lstinline!draw EnvoyerMessageA("message1");!
327 \par\hfill\includegraphics{CommandeEvenements
.8}
330 \item[Groupe
{\sffamily Contrôle
}]\hfil\newline
332 \item[\textbullet]\lstinline!draw Attendre("
\opOp{$
\opSimple{10}\bm{+
}\opSimple{40}$
}");!
333 \par\hfill\includegraphics{CommandeControle
.1}
334 \item[\textbullet]\lstinline!draw AttendreJ("
\opOp{$
\opSimple{10}\bm{+
}\opMouv{Abscisse x
}\bm{=
}\opSimple{20}$
}");!
335 \par\hfill\includegraphics{CommandeControle
.6}
336 \item[\textbullet]\lstinline!draw Stop("ce script");!
337 \par\hfill\includegraphics{CommandeControle
.8}
338 \item[\textbullet]\lstinline!draw CommencerClone;!
339 \par\hfill\includegraphics{CommandeControle
.9}
340 \item[\textbullet]\lstinline!draw CreerClone("Lutin1");!
341 \par\hfill\includegraphics{CommandeControle
.10}
342 \item[\textbullet]\lstinline!draw SupprimerClone;!
343 \par\hfill\includegraphics{CommandeControle
.11}
345 \begin{lstlisting
}[frame=tb
]
346 draw Repeter1("
\opOp{$
\opSimple{10}\bm{+
}\opSimple{40}$
}");
347 draw LigneVide("Bonjour");
348 draw FinBlocRepeter1(
10);
350 \par\hfill\includegraphics{CommandeControle
.2}
352 \begin{lstlisting
}[frame=tb
]
354 draw LigneVide("Bonjour");
355 draw FinBlocRepeterI1(
10);
357 \par\hfill\includegraphics{CommandeControle
.3}
358 \par On remarquera ici la distinction
\lstinline!FinBlocRepeter1! et
\lstinline!FinBlocRepeterI1!. Le premier autorise une suite à l'algorithme (par la présence du cadre
\og puzzle
\fg), le deuxième non.
359 \
\Une deuxième remarque concerne la
\og sortie
\fg\ des blocs
\lstinline!Repeter! (elle est aussi valable pour les blocs
\lstinline!Si!
\ldots\lstinline!alors!). Comme l'indique la figure
\ref{fig:pbsortiebloc
} et contrairement à
\lstinline!Scratch!, j'ai
{\em choisi
}\footnote{Par commodité de programmation, par esthétique et aussi par conception de la sortie d'un tel bloc.
} de ne pas faire de distinction
\og puzzle / non puzzle
\fg\ en fin de boucle (ou test).
362 \includegraphics[width=
0.5\linewidth]{Scratchpbsortiebloc-
1}\hfill\includegraphics{SortieBloc
.1}
363 \caption{Comparaison Scratch /
\MP\ pour l'affichage des
\og sorties
\fg\ de boucles et tests.
}
364 \label{fig:pbsortiebloc
}
367 \`A noter dans le code
\MP\ de cet exemple, l'utilisation du paramètre
\lstinline! _coinprec ! afin de placer différentes partie d'un algorithme au sein d'une même figure
\MP.
368 \begin{lstlisting
}[frame=tb
]
370 draw FinBlocRepeter1(
10);
371 _coinprec:=_coinprec+(
0,-
1cm);
372 draw Si2("
\opOp{$
\opVar{i
}\bm{<
}10$
}");
377 \begin{lstlisting
}[frame=tb
]
378 draw Si1("
\opOp{$
\opSimple{10}\bm{+
}\opMouv{Abscisse x
}%
379 \bm{=
}\opSimple{20}$
}");
380 draw LigneVide("Bonjour");
383 \par\hfill\includegraphics{CommandeControle
.4}
385 \begin{lstlisting
}[frame=tb
]
386 draw Si1("
\opOp{$
\opSimple{10}\bm{+
}\opMouv{Abscisse x
}%
387 \bm{=
}\opSimple{20}$
}");
388 draw LigneVide("Bonjour");
390 draw LigneVide("Bonjour");
393 \par\hfill\includegraphics{CommandeControle
.5}
395 \begin{lstlisting
}[frame=tb
]
396 draw RepeterJ1("
\opOp{$
\opSimple{10}\bm{+
}\opMouv{Abscisse x
}%
397 \bm{=
}\opSimple{20}$
}");
398 draw LigneVide("Bonjour");
399 draw FinBlocRepeter1(
10);
401 \par\hfill\includegraphics{CommandeControle
.7}
404 \item[Groupe
{\sffamily Capteurs
}]\hfil\newline
406 \item[\textbullet]\begin{filecontents*
}{capteur1.txt
}
407 draw Demander("Quel est votre prénom ?");
409 \lstinputlisting[inputencoding=utf8/
latin1]{capteur1.txt
}
410 \par\hfill\includegraphics{CommandeCapteurs
.1}
411 \item[\textbullet]\lstinline!draw ActiverVideo("active");!
412 \par\hfill\includegraphics{CommandeCapteurs
.2}
413 \item[\textbullet]\lstinline!draw TransparenceVideo("
\opOp{$
\opSimple{17}\bm{+
}\opSimple{25}$
}");!
414 \par\hfill\includegraphics{CommandeCapteurs
.3}
415 \item[\textbullet]\lstinline!draw ReinitChrono;!
416 \par\hfill\includegraphics{CommandeCapteurs
.4}
418 Les
\og opérateurs
\fg
420 \begin{minipage
}{0.8\linewidth}
421 \includegraphics{CommandeCapteurs
.5}\par
422 \includegraphics{CommandeCapteurs
.6}\hfill \includegraphics{CommandeCapteurs
.7}\par
423 \includegraphics{CommandeCapteurs
.19}\par
424 \includegraphics{CommandeCapteurs
.20}\hfill\includegraphics{CommandeCapteurs
.8}
425 \par\includegraphics{CommandeCapteurs
.9}\hfill \includegraphics{CommandeCapteurs
.10}\hfill\includegraphics{CommandeCapteurs
.11}
426 \par\includegraphics{CommandeCapteurs
.12}\hfill \includegraphics{CommandeCapteurs
.13}\par
427 \includegraphics{CommandeCapteurs
.14}\hfill\includegraphics{CommandeCapteurs
.15}
428 \par\includegraphics{CommandeCapteurs
.16}\hfill
429 \includegraphics{CommandeCapteurs
.17}\hfill\includegraphics{CommandeCapteurs
.18}
432 s'obtiennent par les commandes
\LaTeX\
\lstinline!
\opCap{}! et
\lstinline!
\opCapCap{}!.
433 Néanmoins, il faut parfois un codage conséquent. Par exemple, voici un capteur et son code.
434 \par\vspace{1em
}\par\begin{minipage
}{0.3\linewidth}
435 \includegraphics{CommandeCapteurs
.7}
438 \begin{minipage
}{0.65\linewidth}
440 \begin{lstlisting
}[frame=tb
]
442 \definecolor{Magenta
}{rgb
}{1,
0,
1}%
443 \colorbox{Magenta
}{\textcolor{white
}{%
445 \definecolor{LGray
}{gray
}{0.85}%
446 \colorbox{LGray
}{\textcolor{white
}{%
451 \
\Un peu barbare, non ? Mais, cela ne nécessitera qu'un simple copier-coller pour les autres utilisations
\ldots%}
452 \par\vspace*
{2em
}\par
453 \item[Groupe
{\sffamily Opérateurs
}]\hfil\newline
456 \begin{minipage
}{0.8\linewidth}
457 \includegraphics{CommandeOperateurs
.1}\hfill\includegraphics{CommandeOperateurs
.2}\hfill\includegraphics{CommandeOperateurs
.3}\hfill
458 \includegraphics{CommandeOperateurs
.4}\par
459 \includegraphics{CommandeOperateurs
.5}\par
460 \includegraphics{CommandeOperateurs
.6}\hfill \includegraphics{CommandeOperateurs
.7}\hfill\includegraphics{CommandeOperateurs
.8}
461 \par\includegraphics{CommandeOperateurs
.9}\hfill \includegraphics{CommandeOperateurs
.10}\hfill\includegraphics{CommandeOperateurs
.11}
462 \par\includegraphics{CommandeOperateurs
.12}\hfill \includegraphics{CommandeOperateurs
.13}\par
463 \includegraphics{CommandeOperateurs
.14}
464 \par\includegraphics{CommandeOperateurs
.15}\hfill\includegraphics{CommandeOperateurs
.16}\hfill\includegraphics{CommandeOperateurs
.17}
467 s'obtiennent par les commandes
\LaTeX\
\lstinline!
\opOp{}! et
\lstinline!
\opSousOp{}!.
468 \
\Afin de rapprocher le package des conventions d'écriture des opérations, le choix du $
\times$ à la place de * s'est imposé. Néanmoins, cela peut être discuté et modifié
\ldots
470 \item[Groupe
{\sffamily Ajouter blocs
}]\hfil\newline
472 \item[\textbullet]\lstinline!draw NouveauBloc("Pentagone");!
473 \par\hfill\includegraphics{CommandeBloc
.1}
474 \item[\textbullet]\lstinline!draw NouveauBloc("Pentagone
\opBloc{cote
}");!
475 \par\hfill\includegraphics{CommandeBloc
.3}
476 \item[\textbullet]\lstinline!draw Bloc("Pentagone");!
477 \par\hfill\includegraphics{CommandeBloc
.2}
479 \item[Groupe
{\sffamily Divers
}]\hfil\newline
480 D'un point de vue pédagogique, il m'est apparu nécessaire d'ajouter la possibilité de donner l'illusion d'un algorithme
\og vide
\fg. J'ai donc créé la commande
\lstinline!LigneVide! qui demande un argument simple (on pourra se reporter aux exemples du groupe
{\sffamily Contrôle
}\footnote{On peut obtenir le même résultat avec le paramètre
\lstinline! _coinprec ! mais la précision de placement me semble plus délicate à obtenir.
}).
481 \
\On aura également à disposition
\lstinline!CommandeVide("Bonjour!")! afin de faire compléter un algorithme par les élèves.
484 \begin{minipage
}{0.4\linewidth}
485 \includegraphics{ExCommandeVide
.1}
488 \begin{minipage
}{0.5\linewidth}
489 \begin{filecontents*
}{CommandeVide.txt
}
494 draw CommandeVide("Tourner à droite
%
496 draw FinBlocRepeter1(
10);
499 \lstinputlisting[inputencoding=utf8/
latin1,frame=tb
]{CommandeVide.txt
}
501 \caption{Utilisation de
\lstinline!CommandeVide!
}
502 \label{fig:CommandeVide
}
505 Terminons cette liste de commandes par un algorithme associé à la suite de Syracuse :)
506 \
[\includegraphics[scale=
0.9]{Syracuse
.1}\
]
507 \begin{filecontents*
}{Syracuse.txt
}
510 draw SupprimerList("
\opSimple{tout
}","Suite");
511 draw Demander("
\opSimple{Quel est le nombre choisi ?
}");
512 draw AjouterList("
\opCap{réponse
}","Suite");
513 draw MettreVar("pas",
1);
515 draw Si2("
\opOp{\opList{élément
\opVar{pas
} de
\opSousList{Suite
}} modulo
\opSimple{2}%
516 \,$
\bm{=
}$\,
\opSimple{0}}");
517 draw MettreVar("résultat","
\opOp{\opList{élément
\opVar{pas
} de
\opSousList{Suite
}}%
518 \,$
\bm{/
}$\,
\opSimple{2}}");
520 draw MettreVar("résultat","
\opOp{\opSimple{3}\,$
\bm{\times}$\,
\opList{élément
\opVar{pas
}%
521 de
\opSousList{Suite
}}\,$
\bm{+
}$\,
\opSimple{1}}");
523 draw Si3("
\opList{\opSousList{Suite
} contient
\opVar{résultat
} ?
}");
526 draw AjouterList("
\opVar{résultat
}","Suite");
527 draw AjouterVar("pas",
1);
529 draw FinBlocRepeter1(
10);
533 \lstinputlisting[inputencoding=utf8/
latin1,frame=tb
]{Syracuse.txt
}
536 \section{Quelques exemples
}
537 \subsection{Sujet de Brevet des collèges
}
541 % \includegraphics{Scratch2-2}
542 %\caption{Figure du Sujet 0 de mathématiques du Brevet des Collèges}
547 \includegraphics{Scratch2-
2}\par
548 \includegraphics[scale=
0.85]{Scratch2-
3}\kern0.05
\linewidth\includegraphics{Algo3.1
}
549 \caption{Figure du Sujet
0 - versions Scratch et
\MP}
552 %\begin{minipage}{0.5\linewidth}
554 \begin{lstlisting
}[firstnumber=
1,frame=tb
]
564 draw FinBlocRepeter1(
10);
568 draw FinBlocRepeter2(
10);
573 \subsection{\OE uvre d'art
}
576 \includegraphics[width=
0.7\linewidth]{Morellet
}
578 \caption{François Morellet - Oeuvre Pi piquant,
1=
1°,
38 décimales
}
580 \
[\includegraphics[width=
0.7\linewidth]{Ex-Morellet
.1}\
]
581 \begin{filecontents*
}{Morellet.txt
}
582 beginfig(
1)
%François Morellet - Oeuvre Pi piquant, 1=1°, 38 décimales
588 draw Tournerg("
\opList{élément
\opSimple{1} de
\opSousList{Pi
}}");
590 draw MettreVar("varpi","
\opSimple{2}");
591 draw RepeterJ1("
\opOp{\opVar{varpi
}\,$
\bm{>
}$\,
38}");
592 draw Si2("$
\opOp{\opVar{varpi
}\mbox{ modulo
}\opSimple{2}\,=\,
\opSimple{0}}$");
593 draw Tournerg("$
\opOp{\opSimple{180}}\bm{-
}\opList{élément
\opVar{varpi
}
594 de
\opSousList{pi
}}$");
596 draw Tournerd("$
\opOp{\opSimple{180}}-
\opList{élément
\opVar{varpi
} de
\opSousList{pi
}}$");
599 draw AjouterVar("varpi","
\opSimple{1}");
600 draw FinBlocRepeter1(
10);
605 \lstinputlisting[inputencoding=utf8/
latin1,frame=tb
]{Morellet.txt
}
608 \subsection{Une
\og spirale
\fg}
611 \begin{minipage
}{0.4\linewidth}
612 \
[\includegraphics[scale=
0.8]{ex-tice74.1
}\
]
613 {\tiny Source :
\url{http://www.ac-grenoble.fr/tice74/spip.php?article1219
}}
616 \begin{minipage
}{0.55\linewidth}
617 \begin{lstlisting
}[frame=tb
]
624 draw MettreVar("i",
1);
625 draw RepeterJ1("
\opOp{$
\opVar{i
}\bm{=
}%
627 draw Avancer("
\opVar{i
}");
628 draw AjouterVar("i",
1);
630 draw FinBlocRepeter1(
10);
634 \caption{Figure géométrique - Code Scratch
}
637 \
[\includegraphics[scale=
1]{ex-tice74-scratch
.1}\
]
639 \subsection{Triangle de Sierpinski
}
642 \includegraphics[scale=
0.5]{Ex-Serpinski
.1}\par
643 \includegraphics{Ex-Serpinski-scratch
.1}
644 \caption{Triangle de Sierpinski - Code Scratch et
\MP}
647 %\begin{lstlisting}[frame=tb]
648 \begin{filecontents*
}{Sierpinski.txt
}
649 beginfig(
1);
%https://sites.google.com/site/stjomaths/scratch
651 draw Aller(-
200,-
150);
655 draw Demander("
\opSimple{rang ?
}");
656 draw MettreVar("rang","
\opCap{réponse
}");
657 draw Demander("
\opSimple{dimension du motif ?
}");
658 draw MettreVar("rang","
\opCap{réponse
}");
659 draw Bloc("Sierpinski
\opBloc{rang
} \opBloc{triangles
}");
660 _coinprec:=(
8.5cm,
0);
661 draw NouveauBloc("Sierpinski
\opBloc{rang
} \opBloc{triangles
}");
662 draw Si1("
\opOp{non $
\opBloc{rang
}\bm{=
}0$
}");
664 draw Bloc("Sierpinski
\opOp{$
\opBloc{rang
}\bm{-
}\opSimple{1}$
}%
665 \opOp{$
\opBloc{triangles
}\,
\bm{/
}\,
\opSimple{2}$
}");
666 draw Avancer("
\opBloc{triangles
}");
668 draw FinBlocRepeter2(
10);
674 \lstinputlisting[inputencoding=utf8/
latin1,frame=tb
]{Sierpinski.txt
}
679 \item[16/
02/
2017] {\bfseries Version
0.59} - Correction des commandes
{\sffamily Dire
},
{\sffamily DireT
},
{\sffamily Penser
},
{\sffamily PenserT
}. Mise à jour de la documentation (informations sur l'installation du package).
680 \item[15/
02/
2017] {\bfseries Version
0.57} - Correction de problèmes mineurs d'affichage. Correction de la documentation.
681 \item[14/
02/
2017] {\bfseries Version
0.55} - Mise à jour de la documentation.
682 \item[13/
02/
2017] {\bfseries Version
0.53} - Ajout des chanfreins sur les blocs. Correction de
\og doublons
\fg\ de commandes. Mise à jour de la documentation.
683 \item[05/
02/
2017] {\bfseries Version
0.51} - Sur les conseils de Maxime Chupin et Thierry Pasquier, travail sur les couleurs (mise en accord avec celles de Scratch et personnalisation possible). Passage des majuscules aux minuscules pour les blocs.
684 \item[21/
01/
2017] {\bfseries Version
0.5} - Publication sur
\url{www.melusine.eu.org/syracuse/
}
685 \item[19/
01/
2017] {\bfseries Version
0.32} - Ajout d'éléments de présentation ($
\blacktriangledown$).
686 \item[18/
01/
2017] {\bfseries Version
0.31} - Ajout du groupe
{\sffamily Son
}.
687 \item[15/
01/
2017] {\bfseries Version
0.3} - Modification du code. Conception de la documentation.
688 \item[08/
01/
2017] {\bfseries Version
0.2} - Ajout des commandes des groupes
{\sffamily Données
} et
{\sffamily Capteurs
}.
689 \item[06/
01/
2017] {\bfseries Version
0.15} - Ajout des commandes du groupe
{\sffamily Ajouter blocs
}.
690 \item[05/
01/
2017] {\bfseries Version
0.1} - Sont disponibles les commandes des groupes
{\sffamily Mouvement
},
{\sffamily Apparence
},
{\sffamily Stylo
},
{\sffamily Évènements
},
{\sffamily Contrôle
}.