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("
\opSimple{Hello
}",
2);!
177 \par\hfill\includegraphics{CommandeApparence
.1}
178 \item[\textbullet]\lstinline!draw Dire("
\opSimple{Hello
}");!
179 \par\hfill\includegraphics{CommandeApparence
.2}
180 \item[\textbullet]\lstinline!draw PenserT("
\opSimple{Hmm...
}",
2);!
181 \par\hfill\includegraphics{CommandeApparence
.3}
182 \item[\textbullet]\lstinline!draw Penser("
\opSimple{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("
\opApMenu{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("
\opApMenu{arriere-plan2
}");!
193 \par\hfill\includegraphics{CommandeApparence
.9}
194 \item[\textbullet]\lstinline!draw AjouterEffet("
\opApMenu{couleur
}",
10);!
195 \par\hfill\includegraphics{CommandeApparence
.10}
196 \item[\textbullet]\lstinline!draw MettreEffet("
\opApMenu{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 \vspace{1em
}\par Quand
\og la scène
\fg\ est sélectionnée, on dispose également des commandes :
211 \item[\textbullet]\lstinline!draw BasculerARA("
\opApMenu{arriere-plan2
}");!
212 \par\hfill\includegraphics{CommandeApparence
.20}
213 \item [\textbullet]\lstinline!draw ARSuivant;!
214 \par\hfill\includegraphics{CommandeApparence
.21}
216 \par\vspace*
{2em
}\par Les
\og opérateurs
\fg\
217 \
[\includegraphics{CommandeApparence
.17}\kern0.1
\linewidth\includegraphics{CommandeApparence
.18}\kern0.1
\linewidth\includegraphics{CommandeApparence
.19}\kern0.1
\linewidth\includegraphics{CommandeApparence
.22}\
]
218 s'obtiennent avec la commande
\LaTeX\
\lstinline!
\opAp{}!.
219 \par\vspace*
{2em
}\par
220 \item[Groupe
{\sffamily Son
}]\hfil\newline
222 \item[\textbullet]\lstinline!draw Jouer("miaou");!
223 \par\hfill\includegraphics{CommandeSon
.1}
224 \item[\textbullet]\lstinline!draw JouerT("miaou");!
225 \par\hfill\includegraphics{CommandeSon
.2}
226 \item[\textbullet]\lstinline!draw ArreterSon;!
227 \par\hfill\includegraphics{CommandeSon
.3}
228 \item[\textbullet]\lstinline!draw Tambour(
2,
0.25);!
229 \par\hfill\includegraphics{CommandeSon
.4}
230 \item[\textbullet]\lstinline!draw Pause(
0.25);!
231 \par\hfill\includegraphics{CommandeSon
.5}
232 \item[\textbullet]\lstinline!draw JouerNote(
50,
0.25);!
233 \par\hfill\includegraphics{CommandeSon
.6}
234 \item[\textbullet]\lstinline!draw ChoisirInstrument(
17);!
235 \par\hfill\includegraphics{CommandeSon
.7}
236 \item[\textbullet]\lstinline!draw AjouterVol(-
10);!
237 \par\hfill\includegraphics{CommandeSon
.8}
238 \item[\textbullet]\lstinline!draw MettreVol(
15);!
239 \par\hfill\includegraphics{CommandeSon
.9}
240 \item[\textbullet]\lstinline!draw AjouterTempo(
20);!
241 \par\hfill\includegraphics{CommandeSon
.10}
242 \item[\textbullet]\lstinline!draw MettreTempo(
15);!
243 \par\hfill\includegraphics{CommandeSon
.11}
245 Les
\og opérateurs
\fg
246 \
[\includegraphics{CommandeSon
.12}\kern0.1
\linewidth\includegraphics{CommandeSon
.13}\
]
247 s'obtiennent par la commande
\LaTeX\
\lstinline!
\opSon{}!.
248 \
[\includegraphics{CommandeSon
.14}\
]
249 \begin{lstlisting
}[frame=tb
]
250 draw DireT("
\opOp{Regroupe
\opSimple{Le volume actuel est
}%
253 \par\vspace*
{2em
}\par
254 \item[Groupe
{\sffamily Stylo
}]\hfil\newline
256 \item[\textbullet]\lstinline!draw Effacer;!
257 \par\hfill\includegraphics{CommandeStylo
.1}
258 \item[\textbullet]\lstinline!draw Estampiller;!
259 \par\hfill\includegraphics{CommandeStylo
.2}
260 \item[\textbullet]\lstinline!draw PoserStylo;!
261 \par\hfill\includegraphics{CommandeStylo
.3}
262 \item[\textbullet]\lstinline!draw ReleverStylo;!
263 \par\hfill\includegraphics{CommandeStylo
.4}
264 \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
}.
}
265 \par\hfill\includegraphics{CommandeStylo
.5}
266 \item[\textbullet]\lstinline!draw AjouterCS("
\opOp{$
\opSimple{15}\bm{+
}\opSimple{10}$
}");!
267 \par\hfill\includegraphics{CommandeStylo
.6}
268 \item[\textbullet]\lstinline!draw MettreCS(
25);!
269 \par\hfill\includegraphics{CommandeStylo
.7}
270 \item[\textbullet]\lstinline!draw AjouterIS("
\opOp{$
\opSimple{25}\bm{-
}\opSimple{10}$
}");!
271 \par\hfill\includegraphics{CommandeStylo
.8}
272 \item[\textbullet]\lstinline!draw MettreIS(
15);!
273 \par\hfill\includegraphics{CommandeStylo
.9}
274 \item[\textbullet]\lstinline!draw AjouterTS(
12);!
275 \par\hfill\includegraphics{CommandeStylo
.10}
276 \item[\textbullet]\lstinline!draw MettreTS("
\opOp{$
\opSimple{15}\bm{\times}\opSimple{10}$
}");!
277 \par\hfill\includegraphics{CommandeStylo
.11}
280 \item[Groupe
{\sffamily Données
}]\hfil\newline
282 \item[\textbullet]\lstinline!draw MettreVar("pi",
0);!
283 \par\hfill\includegraphics{CommandeVariable
.1}
284 \item[\textbullet]\lstinline!draw AjouterVar("pi","
\opOp{$
\opSimple{15}\bm{+
}\opSimple{10}$
}");!
285 \par\hfill\includegraphics{CommandeVariable
.2}
286 \item[\textbullet]\lstinline!draw MontrerVar("pi");!
287 \par\hfill\includegraphics{CommandeVariable
.3}
288 \item[\textbullet]\lstinline!draw CacherVar("pi");!
289 \par\hfill\includegraphics{CommandeVariable
.4}
290 \item[\textbullet]\lstinline!draw AjouterList("
\opSimple{\LaTeX}","Listepi");!
291 \par\hfill\includegraphics{CommandeVariable
.5}
292 \item[\textbullet]\lstinline!draw SupprimerList("
\opSimple{\LaTeX}","Listepi");!
293 \par\hfill\includegraphics{CommandeVariable
.6}
294 \item[\textbullet]\lstinline!draw InsererList("
\opSimple{\MP}",
1,"Listepi");!
295 \par\hfill\includegraphics{CommandeVariable
.7}
296 \item[\textbullet]\lstinline!draw RemplacerList(
3,"Listepi","
\opOp{$
\opSimple{4}\bm{+
}\opSimple{5}$
}");!
297 \par\hfill\includegraphics{CommandeVariable
.8}
298 \item[\textbullet]\lstinline!draw MontrerList("Listepi");!
299 \par\hfill\includegraphics{CommandeVariable
.9}
300 \item[\textbullet]\lstinline!draw CacherList("Listepi");!
301 \par\hfill\includegraphics{CommandeVariable
.10}
303 \par\vspace*
{2em
}\par Les
\og opérateurs
\fg
305 \begin{minipage
}{0.8\linewidth}
306 \includegraphics{CommandeVariable
.11}\hfill\includegraphics{CommandeVariable
.12}\hfill \includegraphics{CommandeVariable
.13}\par
307 \includegraphics{CommandeVariable
.14}\hfill \includegraphics{CommandeVariable
.15}
310 s'obtiennent par les commandes
\LaTeX\
\lstinline!
\opVar{}!,
\lstinline!
\opList{}! et
\lstinline!
\opSousList{}!.
313 \includegraphics{CommandeVariable
.15}
314 % \begin{minipage}{0.6\linewidth}
315 \begin{lstlisting
}[frame=tb
]
316 label(LATEX("
\opList{\opSousList{Pythagore
}
317 contient
\opSimple{(
3;
4;
5)
} ?
}"),(
0,
0));
321 \par\vspace*
{2em
}\par
322 \item[Groupe
{\sffamily \'Evènement
}]\hfil\newline
324 \item[\textbullet]\lstinline!draw Drapeau;!
325 \par\hfill\includegraphics{CommandeEvenements
.1}
326 \item[\textbullet]\lstinline!draw QPresse("espace");!
327 \par\hfill\includegraphics{CommandeEvenements
.2}
328 \item[\textbullet]\lstinline!draw QLutinPresse;!
329 \par\hfill\includegraphics{CommandeEvenements
.3}
330 \item[\textbullet]\lstinline!draw QBasculeAR("arriere-plan1");!
331 \par\hfill\includegraphics{CommandeEvenements
.4}
332 \item[\textbullet]\lstinline!draw QVolumeSup("Volume sonore",
10);!
333 \par\hfill\includegraphics{CommandeEvenements
.5}
334 \item[\textbullet]\lstinline!draw QRecevoirMessage("message1");!
335 \par\hfill\includegraphics{CommandeEvenements
.6}
336 \item[\textbullet]\lstinline!draw EnvoyerMessage("message1");!
337 \par\hfill\includegraphics{CommandeEvenements
.7}
338 \item[\textbullet]\lstinline!draw EnvoyerMessageA("message1");!
339 \par\hfill\includegraphics{CommandeEvenements
.8}
342 Quand
\og la scène
\fg\ est sélectionnée, on dispose de :
344 \item[\textbullet]\lstinline!draw QScenePressee;!
345 \par\hfill\includegraphics{CommandeEvenements
.9}\footnote{C'est le seul endroit où il y a une majuscule dans les notations
{\sffamily Scratch
}\ldots}
348 \item[Groupe
{\sffamily Contrôle
}]\label{Groupecontrole
}\hfil\newline
350 \item[\textbullet]\lstinline!draw Attendre("
\opOp{$
\opSimple{10}\bm{+
}\opSimple{40}$
}");!
351 \par\hfill\includegraphics{CommandeControle
.1}
352 \item[\textbullet]\lstinline!draw AttendreJ("
\opOp{$
\opSimple{10}\bm{+
}\opMouv{Abscisse x
}\bm{=
}\opSimple{20}$
}");!
353 \par\hfill\includegraphics{CommandeControle
.6}
354 \item[\textbullet]\lstinline!draw Stop("ce script");!
355 \par\hfill\includegraphics{CommandeControle
.8}
357 \item[\textbullet]\lstinline!draw CommencerClone;!
358 \par\hfill\includegraphics{CommandeControle
.9}
359 \item[\textbullet]\lstinline!draw CreerClone("Lutin1");!
360 \par\hfill\includegraphics{CommandeControle
.10}
361 \item[\textbullet]\lstinline!draw SupprimerClone;!
362 \par\hfill\includegraphics{CommandeControle
.11}
364 \begin{lstlisting
}[frame=tb
]
365 draw Repeter1("
\opOp{$
\opSimple{10}\bm{+
}\opSimple{40}$
}");
366 draw LigneVide("Bonjour");
367 draw FinBlocRepeter1(
10);
369 \par\hfill\includegraphics{CommandeControle
.2}
371 \begin{lstlisting
}[frame=tb
]
373 draw LigneVide("Bonjour");
374 draw FinBlocRepeterI1(
10);
376 \par\hfill\includegraphics{CommandeControle
.3}
377 \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.
378 \
\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).
381 \includegraphics[width=
0.5\linewidth]{Scratchpbsortiebloc-
1}\hfill\includegraphics{SortieBloc
.1}
382 \caption{Comparaison Scratch /
\MP\ pour l'affichage des
\og sorties
\fg\ de boucles et tests.
}
383 \label{fig:pbsortiebloc
}
386 \`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.
387 \begin{lstlisting
}[frame=tb
]
389 draw FinBlocRepeter1(
10);
390 _coinprec:=_coinprec+(
0,-
1cm);
391 draw Si2("
\opOp{$
\opVar{i
}\bm{<
}10$
}");
396 \begin{lstlisting
}[frame=tb
]
397 draw Si1("
\opOp{$
\opSimple{10}\bm{+
}\opMouv{Abscisse x
}%
398 \bm{=
}\opSimple{20}$
}");
399 draw LigneVide("Bonjour");
402 \par\hfill\includegraphics{CommandeControle
.4}
404 \begin{lstlisting
}[frame=tb
]
405 draw Si1("
\opOp{$
\opSimple{10}\bm{+
}\opMouv{Abscisse x
}%
406 \bm{=
}\opSimple{20}$
}");
407 draw LigneVide("Bonjour");
409 draw LigneVide("Bonjour");
412 \par\hfill\includegraphics{CommandeControle
.5}
414 \begin{lstlisting
}[frame=tb
]
415 draw RepeterJ1("
\opOp{$
\opSimple{10}\bm{+
}\opMouv{Abscisse x
}%
416 \bm{=
}\opSimple{20}$
}");
417 draw LigneVide("Bonjour");
418 draw FinBlocRepeter1(
10);
420 \par\hfill\includegraphics{CommandeControle
.7}
423 \item[Groupe
{\sffamily Capteurs
}]\hfil\newline
425 \item[\textbullet]\begin{filecontents*
}{capteur1.txt
}
426 draw Demander("Quel est votre prénom ?");
428 \lstinputlisting[inputencoding=utf8/
latin1]{capteur1.txt
}
429 \par\hfill\includegraphics{CommandeCapteurs
.1}
430 \item[\textbullet]\lstinline!draw ActiverVideo("active");!
431 \par\hfill\includegraphics{CommandeCapteurs
.2}
432 \item[\textbullet]\lstinline!draw TransparenceVideo("
\opOp{$
\opSimple{17}\bm{+
}\opSimple{25}$
}");!
433 \par\hfill\includegraphics{CommandeCapteurs
.3}
434 \item[\textbullet]\lstinline!draw ReinitChrono;!
435 \par\hfill\includegraphics{CommandeCapteurs
.4}
437 Les
\og opérateurs
\fg
439 \begin{minipage
}{0.8\linewidth}
440 \includegraphics{CommandeCapteurs
.5}\par
441 \includegraphics{CommandeCapteurs
.6}\hfill \includegraphics{CommandeCapteurs
.7}\par
442 \includegraphics{CommandeCapteurs
.19}\par
443 \includegraphics{CommandeCapteurs
.20}\hfill\includegraphics{CommandeCapteurs
.8}
444 \par\includegraphics{CommandeCapteurs
.9}\hfill \includegraphics{CommandeCapteurs
.10}\hfill\includegraphics{CommandeCapteurs
.11}
445 \par\includegraphics{CommandeCapteurs
.12}\hfill \includegraphics{CommandeCapteurs
.13}\par
446 \includegraphics{CommandeCapteurs
.14}\hfill\includegraphics{CommandeCapteurs
.15}
447 \par\includegraphics{CommandeCapteurs
.16}\hfill
448 \includegraphics{CommandeCapteurs
.17}\hfill\includegraphics{CommandeCapteurs
.18}
451 s'obtiennent par les commandes
\LaTeX\
\lstinline!
\opCap{}! et
\lstinline!
\opCapCap{}!.
452 Néanmoins, il faut parfois un codage conséquent. Par exemple, voici un capteur et son code.
453 \par\vspace{1em
}\par\begin{minipage
}{0.3\linewidth}
454 \includegraphics{CommandeCapteurs
.7}
457 \begin{minipage
}{0.65\linewidth}
459 \begin{lstlisting
}[frame=tb
]
461 \definecolor{Magenta
}{rgb
}{1,
0,
1}%
462 \colorbox{Magenta
}{\textcolor{white
}{%
464 \definecolor{LGray
}{gray
}{0.85}%
465 \colorbox{LGray
}{\textcolor{white
}{%
470 \
\Un peu barbare ? Non, un simple copier-coller sera nécessaire pour les futures utilisations
\ldots%}
471 %\par\vspace*{2em}\par
472 \item[Groupe
{\sffamily Opérateurs
}]\hfil\newline
475 \begin{minipage
}{0.8\linewidth}
476 \includegraphics{CommandeOperateurs
.1}\hfill\includegraphics{CommandeOperateurs
.2}\hfill\includegraphics{CommandeOperateurs
.3}\hfill
477 \includegraphics{CommandeOperateurs
.4}\par
478 \includegraphics{CommandeOperateurs
.5}\par
479 \includegraphics{CommandeOperateurs
.6}\hfill \includegraphics{CommandeOperateurs
.7}\hfill\includegraphics{CommandeOperateurs
.8}
480 \par\includegraphics{CommandeOperateurs
.9}\hfill \includegraphics{CommandeOperateurs
.10}\hfill\includegraphics{CommandeOperateurs
.11}
481 \par\includegraphics{CommandeOperateurs
.12}\hfill \includegraphics{CommandeOperateurs
.13}\par
482 \includegraphics{CommandeOperateurs
.14}
483 \par\includegraphics{CommandeOperateurs
.15}\hfill\includegraphics{CommandeOperateurs
.16}\hfill\includegraphics{CommandeOperateurs
.17}
486 s'obtiennent par les commandes
\LaTeX\
\lstinline!
\opOp{}! et
\lstinline!
\opSousOp{}!.
487 \
\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
489 \item[Groupe
{\sffamily Ajouter blocs
}]\hfil\newline
491 \item[\textbullet]\lstinline!draw NouveauBloc("Pentagone");!
492 \par\hfill\includegraphics{CommandeBloc
.1}
493 \item[\textbullet]\lstinline!draw NouveauBloc("Pentagone
\opBloc{cote
}");!
494 \par\hfill\includegraphics{CommandeBloc
.3}
495 \item[\textbullet]\lstinline!draw Bloc("Pentagone");!
496 \par\hfill\includegraphics{CommandeBloc
.2}
498 \item[Groupe
{\sffamily Divers
}]\hfil\newline
499 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.
} à la page
\pageref{Groupecontrole
}).
500 \
[\includegraphics{CommandeControle
.5}\
]
501 On aura également à disposition
\lstinline!CommandeVide("Bonjour!")! afin de faire compléter un algorithme par les élèves.
504 \begin{minipage
}{0.4\linewidth}
505 \includegraphics{ExCommandeVide
.1}
508 \begin{minipage
}{0.5\linewidth}
509 \begin{filecontents*
}{CommandeVide.txt
}
514 draw CommandeVide("Tourner à droite
%
516 draw FinBlocRepeter1(
10);
519 \lstinputlisting[inputencoding=utf8/
latin1,frame=tb
]{CommandeVide.txt
}
521 \caption{Utilisation de
\lstinline!CommandeVide!
}
522 \label{fig:CommandeVide
}
524 Enfin, il y a la commande
\lstinline!LignePointilles! permettant de faire des
\og raccourcis
\fg\ dans la
525 présentation des algorithmes.
526 \begin{lstlisting
}[frame=tb
]
529 draw LignePointilles;
530 draw CommandeVide("
\opSimple{Je choisis un nombre aleatoirement
%
532 draw CommandeVide("
\opSimple{Je choisis un nombre aleatoirement
%
536 \par\hfill\includegraphics{CommandeDivers
.1}
538 Terminons cette liste de commandes par un algorithme associé à la suite de Syracuse :)
539 \
[\includegraphics[scale=
0.9]{Syracuse
.1}\
]
540 \begin{filecontents*
}{Syracuse.txt
}
543 draw SupprimerList("
\opSimple{tout
}","Suite");
544 draw Demander("
\opSimple{Quel est le nombre choisi ?
}");
545 draw AjouterList("
\opCap{réponse
}","Suite");
546 draw MettreVar("pas",
1);
548 draw Si2("
\opOp{\opList{élément
\opVar{pas
} de
\opSousList{Suite
}} modulo
\opSimple{2}%
549 \,$
\bm{=
}$\,
\opSimple{0}}");
550 draw MettreVar("résultat","
\opOp{\opList{élément
\opVar{pas
} de
\opSousList{Suite
}}%
551 \,$
\bm{/
}$\,
\opSimple{2}}");
553 draw MettreVar("résultat","
\opOp{\opSimple{3}\,$
\bm{\times}$\,
\opList{élément
\opVar{pas
}%
554 de
\opSousList{Suite
}}\,$
\bm{+
}$\,
\opSimple{1}}");
556 draw Si3("
\opList{\opSousList{Suite
} contient
\opVar{résultat
} ?
}");
559 draw AjouterList("
\opVar{résultat
}","Suite");
560 draw AjouterVar("pas",
1);
562 draw FinBlocRepeter1(
10);
566 \lstinputlisting[inputencoding=utf8/
latin1,frame=tb
]{Syracuse.txt
}
569 \section{Quelques exemples
}
570 \subsection{Sujet de Brevet des collèges
}
574 % \includegraphics{Scratch2-2}
575 %\caption{Figure du Sujet 0 de mathématiques du Brevet des Collèges}
580 \includegraphics{Scratch2-
2}\par
581 \includegraphics[scale=
0.85]{Scratch2-
3}\kern0.05
\linewidth\includegraphics{Algo3.1
}
582 \caption{Figure du Sujet
0 - versions Scratch et
\MP}
585 %\begin{minipage}{0.5\linewidth}
587 \begin{lstlisting
}[firstnumber=
1,frame=tb
]
597 draw FinBlocRepeter1(
10);
601 draw FinBlocRepeter2(
10);
606 \subsection{\OE uvre d'art
}
609 \includegraphics[width=
0.7\linewidth]{Morellet
}
611 \caption{François Morellet - Oeuvre Pi piquant,
1=
1°,
38 décimales
}
613 \
[\includegraphics[width=
0.7\linewidth]{Ex-Morellet
.1}\
]
614 \begin{filecontents*
}{Morellet.txt
}
615 beginfig(
1)
%François Morellet - Oeuvre Pi piquant, 1=1°, 38 décimales
621 draw Tournerg("
\opList{élément
\opSimple{1} de
\opSousList{Pi
}}");
623 draw MettreVar("varpi","
\opSimple{2}");
624 draw RepeterJ1("
\opOp{\opVar{varpi
}\,$
\bm{>
}$\,
38}");
625 draw Si2("$
\opOp{\opVar{varpi
}\mbox{ modulo
}\opSimple{2}\,=\,
\opSimple{0}}$");
626 draw Tournerg("$
\opOp{\opSimple{180}}\bm{-
}\opList{élément
\opVar{varpi
}
627 de
\opSousList{pi
}}$");
629 draw Tournerd("$
\opOp{\opSimple{180}}-
\opList{élément
\opVar{varpi
} de
\opSousList{pi
}}$");
632 draw AjouterVar("varpi","
\opSimple{1}");
633 draw FinBlocRepeter1(
10);
638 \lstinputlisting[inputencoding=utf8/
latin1,frame=tb
]{Morellet.txt
}
641 \subsection{Une
\og spirale
\fg}
644 \begin{minipage
}{0.4\linewidth}
645 \
[\includegraphics[scale=
0.8]{ex-tice74.1
}\
]
646 {\tiny Source :
\url{http://www.ac-grenoble.fr/tice74/spip.php?article1219
}}
649 \begin{minipage
}{0.55\linewidth}
650 \begin{lstlisting
}[frame=tb
]
657 draw MettreVar("i",
1);
658 draw RepeterJ1("
\opOp{$
\opVar{i
}\bm{=
}%
660 draw Avancer("
\opVar{i
}");
661 draw AjouterVar("i",
1);
663 draw FinBlocRepeter1(
10);
667 \caption{Figure géométrique - Code Scratch
}
670 \
[\includegraphics[scale=
1]{ex-tice74-scratch
.1}\
]
672 \subsection{Triangle de Sierpinski
}
675 \includegraphics[scale=
0.5]{Ex-Serpinski
.1}\par
676 \includegraphics{Ex-Serpinski-scratch
.1}
677 \caption{Triangle de Sierpinski - Code Scratch et
\MP}
680 %\begin{lstlisting}[frame=tb]
681 \begin{filecontents*
}{Sierpinski.txt
}
682 beginfig(
1);
%https://sites.google.com/site/stjomaths/scratch
684 draw Aller(-
200,-
150);
688 draw Demander("
\opSimple{rang ?
}");
689 draw MettreVar("rang","
\opCap{réponse
}");
690 draw Demander("
\opSimple{dimension du motif ?
}");
691 draw MettreVar("rang","
\opCap{réponse
}");
692 draw Bloc("Sierpinski
\opBloc{rang
} \opBloc{triangles
}");
693 _coinprec:=(
8.5cm,
0);
694 draw NouveauBloc("Sierpinski
\opBloc{rang
} \opBloc{triangles
}");
695 draw Si1("
\opOp{non $
\opBloc{rang
}\bm{=
}0$
}");
697 draw Bloc("Sierpinski
\opOp{$
\opBloc{rang
}\bm{-
}\opSimple{1}$
}%
698 \opOp{$
\opBloc{triangles
}\,
\bm{/
}\,
\opSimple{2}$
}");
699 draw Avancer("
\opBloc{triangles
}");
701 draw FinBlocRepeter2(
10);
707 \lstinputlisting[inputencoding=utf8/
latin1,frame=tb
]{Sierpinski.txt
}
712 \item[07/
03/
2017] {\bfseries Version
0.62} - Ajout d'une commande
{\sffamily LignePointilles
} et mise à jour de la documentation.
713 \item[17/
02/
2017] {\bfseries Version
0.61} - Grâce à Thomas Dehon, ajout des commandes correspondantes à la sélection de
\og la scène
\fg. Mise à jour de la documentation.
714 \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).
715 \item[15/
02/
2017] {\bfseries Version
0.57} - Correction de problèmes mineurs d'affichage. Correction de la documentation.
716 \item[14/
02/
2017] {\bfseries Version
0.55} - Mise à jour de la documentation.
717 \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.
718 \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.
719 \item[21/
01/
2017] {\bfseries Version
0.5} - Publication sur
\url{www.melusine.eu.org/syracuse/
}
720 \item[19/
01/
2017] {\bfseries Version
0.32} - Ajout d'éléments de présentation ($
\blacktriangledown$).
721 \item[18/
01/
2017] {\bfseries Version
0.31} - Ajout du groupe
{\sffamily Son
}.
722 \item[15/
01/
2017] {\bfseries Version
0.3} - Modification du code. Conception de la documentation.
723 \item[08/
01/
2017] {\bfseries Version
0.2} - Ajout des commandes des groupes
{\sffamily Données
} et
{\sffamily Capteurs
}.
724 \item[06/
01/
2017] {\bfseries Version
0.15} - Ajout des commandes du groupe
{\sffamily Ajouter blocs
}.
725 \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
}.