Debian Codegraph @

texmf-dist/tex/latex/scratch3/scratch3.sty

raw
1 % !TeX encoding = UTF-8
2 % Ce fichier contient le code de l'extension "scratch3"
3 %
4 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5 % %
6 \def\scrname {scratch3} %
7 \def\scrver {0.19} %
8 % %
9 \def\scrdate {2022/02/06} %
10 % %
11 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 %
13 % --------------------------------------------------------------------
14 % Author : Christian Tellechea
15 % Status : Maintained
16 % Email : [email protected]
17 % Copyright : Christian Tellechea 2020
18 % Licence : Released under the LaTeX Project Public License v1.3c
19 % or later, see http://www.latex-project.org/lppl.txtf
20 % Files : 1) scratch3.sty
21 % 2) scratch3-fr.tex
22 % 3) scratch3-fr.pdf
23 % 4) README
24 % --------------------------------------------------------------------
25 \@ifpackageloaded{scratch}
26 {\PackageError{scratch3}{scratch3 cannot be used since scratch is already loaded}{}%
27 \endinput
28 }
29 {}
30 \ProvidesPackage{scratch3}[\scrdate\space v\scrver\space Draw scratch3 instructions (CT)]
31 \NeedsTeXFormat{LaTeX2e}
32 \RequirePackage{simplekv,tikz}
33 \usepgflibrary{shapes.misc,arrows.meta}
34 \usetikzlibrary{bending}
35
36 \expandafter\edef\csname scr\string _restorecatcode\endcsname{\catcode`\noexpand\_=\the\catcode`\_\relax}
37 \catcode`\_11
38 \long\def\scr_eearg#1#2{\expandafter\scr_eearg_i\expandafter{#2}{#1}}\let\scr_eexparg\scr_eearg
39 \long\def\scr_eeearg#1#2{\expandafter\expandafter\expandafter\scr_eearg_i\expandafter\expandafter\expandafter{#2}{#1}}%
40 \long\def\scr_eearg_i#1#2{#2{#1}}
41 \long\def\scr_first#1#2{#1}
42 \long\def\scr_second#1#2{#2}
43 \long\def\scr_ifempty#1{\scr_ifempty_i#1\_nil\_nil\scr_second\scr_first\__nil}%
44 \long\def\scr_ifempty_i#1#2\_nil#3#4#5\__nil{#4}
45
46 \newcommand*\numblock[1]{%
47 \color{black}%
48 \footnotesize
49 \bfseries
50 #1%
51 }
52 \newcommand*\resetscratch{\restore[\scrname]\scr_setcolors}
53 \newcommand*\setscratch[1]{\setKV[\scrname]{#1}\scr_setcolors}
54 \newcommand*\setdefaultscratch[1]{\setKVdefault[\scrname]{#1}\scr_setcolors}
55 \def\scr_setcolors{%
56 \scr_normalizedec\scr_fillgray fill gray[0,1]\scr_eearg{\definecolor{scr_fillgray}{gray}}\scr_fillgray
57 \scr_normalizedec\scr_linegray line gray[0,1]\scr_eearg{\definecolor{scr_linegray}{gray}}\scr_linegray
58 \scr_normalizedec\scr_flaggray flag gray[0,1]\scr_eearg{\definecolor{scr_flaggray}{gray}}\scr_flaggray
59 }
60 \expandafter\let\expandafter\scr_ifstar\csname @ifstar\endcsname
61 \def\scr_boolsentinel{17}%
62 \def\scr_ovalsentinel{18}%
63 \def\scr_blockstrut{\vrule height2.1ex depth.9ex width0pt\relax}
64 \def\scr_ovalstrut{\vphantom{\`Ag}}
65 \def\scr_cslet#1{\expandafter\let\csname#1\endcsname}
66 \def\scr_csdef#1{\expandafter\def\csname#1\endcsname}
67 \def\scr_csedef#1{\expandafter\edef\csname#1\endcsname}
68 \def\scr_execfirst#1#2{#1}
69 \def\scr_execsecond#1#2{#2}
70 \def\scr_firsttonil#1#2\_nil{#1}
71 \def\scr_maxdim(#1,#2){\the\dimexpr\ifdim\dimexpr#1-(#2)\relax<0pt #2\else#1\fi\relax}
72 \def\scr_normalizedec#1#2[#3,#4]{%
73 \edef#1{\useKV[\scrname]{#2}}%
74 \ifdim#1pt<#3pt
75 \def#1{#3}%
76 \else
77 \ifdim#1pt>#4pt
78 \def#1{#4}%
79 \fi
80 \fi
81 }
82 \def\scr_normalizedim#1#2[#3,#4]{%
83 \edef#1{\the\dimexpr\useKV[\scrname]{#2}}%
84 \ifdim\dimexpr#1-(#3)\relax<0pt
85 \edef#1{\the\dimexpr#3}%
86 \else
87 \ifdim\dimexpr#1-(#4)\relax>0pt
88 \edef#1{\the\dimexpr#4}%
89 \fi
90 \fi
91 }
92 \newif\if_inpicture
93 \_inpicturefalse
94 \newcount\scr_loopnest
95 \newcount\scr_blocknum
96 \newbox \scr_box
97 \newdimen\scr_yoffset
98 \newdimen\scr_xoffset
99
100 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
101 % dessine un bloc normal %
102 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
103 \def\scr_normalblock#1#2{% #1=couleur #2=texte
104 \def\scr_current_blockcolor{#1}%
105 % \if_inpicture\def\scr_scale{1}\else\scr_normalizedec\scr_scale scale[0.2,5]\fi% bugfix 0.15 (regression) --> bugfix 0.16
106 \def\scr_currentstuff{%
107 \if_pen
108 \scr_drawpen
109 \kern.6em
110 \begingroup
111 \ifboolKV[\scrname]{print}
112 {\color{scr_linegray}}
113 {\color{penvline}}%
114 \vrule width0.5pt
115 \endgroup
116 \kern.6em
117 \fi
118 \useKV[\scrname]{pre text}%
119 \_inpicturetrue
120 \def\scr_scale{1}% bugfix 0.19
121 #2%
122 \scr_blockstrut
123 }%
124 \setbox\scr_box\hbox{%
125 \pgfinterruptpicture
126 \scr_currentstuff
127 \endpgfinterruptpicture
128 }%
129 \edef\scr_boxwd{\scr_maxdim(\wd\scr_box,\scr_minwd)}%
130 \edef\scr_boxht{\the\ht\scr_box}%
131 \edef\scr_totht{\the\dimexpr\ht\scr_box+\dp\scr_box\relax}%
132 \draw[
133 draw={%
134 \ifboolKV[\scrname]{print}
135 {scr_linegray!\scr_contrast!black}
136 {#1dd}
137 },
138 line width=\scr_linewidth,
139 rounded corners=0.4*\scr_ex*\scr_scale,
140 fill={%
141 \ifboolKV[\scrname]{print}
142 {\ifboolKV[\scrname]{fill blocks}
143 {scr_fillgray}
144 {none}%
145 }
146 {#1}%
147 },
148 yshift=\scr_yoffset,
149 xshift=\scr_xoffset
150 ]
151 (0,0)--++(0.66666*\scr_notch,0)--++(\scr_corner,-\scr_corner)--++(\scr_notch,0)--++(\scr_corner,\scr_corner)--++(\scr_boxwd+2*\scr_xsep-\scr_corner*2-\scr_notch*1.66666,0)% ligne sup
152 --++(0,-\scr_totht-\scr_ysepsup-\scr_ysepinf-\scr_corner)% ligne est
153 --++(-\scr_boxwd-2*\scr_xsep+\scr_corner*2+\scr_notch*1.66666,0)--++(-\scr_corner,-\scr_corner)--++(-\scr_notch,0)--++(-\scr_corner,\scr_corner)--++(-0.66666*\scr_notch,0)% ligne sud
154 --cycle;
155 \node[
156 at=(origin),
157 draw=none,
158 anchor=base west,
159 xshift=\scr_xoffset+\scr_xsep,
160 yshift=\scr_yoffset-\scr_boxht-\scr_corner-\scr_ysepsup,
161 text={%
162 \ifboolKV[\scrname]{print}
163 {\useKV[\scrname]{text color}}
164 {white}%
165 }
166 ]
167 (txt\number\scr_blocknum)
168 {\scr_currentstuff};
169 \ifboolKV[\scrname]{num blocks}
170 {\node[
171 at=(origin),
172 draw=none,
173 anchor=base east,
174 xshift=-\scr_numsep,
175 yshift=\scr_yoffset-\scr_boxht-\scr_corner-\scr_ysepsup
176 ]
177 (num)
178 {\scr_eearg\numblock{\number\scr_blocknum}};%
179 }
180 {}%
181 \advance\scr_blocknum1
182 \advance\scr_yoffset\dimexpr-\scr_totht-\scr_ysepsup-\scr_ysepinf-\scr_corner\relax
183 \gdef\scr_blockstop{0}%
184 \_penfalse
185 }
186 \newcommand*\blockspace[1][1]{%
187 \advance\scr_yoffset#1\dimexpr-\scr_blockstruttotht-\scr_ysepsup-\scr_ysepinf-\scr_corner-\scr_linewidth\relax
188 \gdef\scr_blockstop{0}% bugfix 0.19
189 }
190 \newcommand*\blockstop[1]{% #1=texte
191 \def\scr_current_blockcolor{scrcontrol}%
192 \def\scr_currentstuff{%
193 \useKV[\scrname]{pre text}%
194 #1%
195 \scr_blockstrut
196 }%
197 \setbox\scr_box\hbox{%
198 \pgfinterruptpicture
199 \scr_currentstuff
200 \endpgfinterruptpicture
201 }%
202 \edef\scr_boxwd{\scr_maxdim(\wd\scr_box,\scr_minwd)}%
203 \edef\scr_boxht{\the\ht\scr_box}%
204 \edef\scr_totht{\the\dimexpr\ht\scr_box+\dp\scr_box\relax}%
205 \draw[
206 draw={%
207 \ifboolKV[\scrname]{print}
208 {scr_linegray!\scr_contrast!black}
209 {\scr_current_blockcolor dd}%
210 },
211 line width=\scr_linewidth,
212 rounded corners=0.4*\scr_ex*\scr_scale,
213 fill={%
214 \ifboolKV[\scrname]{print}
215 {\ifboolKV[\scrname]{fill blocks}
216 {scr_fillgray}
217 {none}%
218 }
219 {\scr_current_blockcolor}%
220 },
221 yshift=\scr_yoffset,
222 xshift=\scr_xoffset
223 ]
224 (0,0)--++(0.66666*\scr_notch,0)--++(\scr_corner,-\scr_corner)--++(\scr_notch,0)--++(\scr_corner,\scr_corner)--++(\scr_boxwd+2*\scr_xsep-\scr_corner*2-\scr_notch*1.66666,0)% ligne sup
225 --++(0,-\scr_totht-\scr_ysepsup-\scr_ysepinf-\scr_corner)--++(-\scr_boxwd-2*\scr_xsep,0)--cycle;
226 \node[
227 at=(origin),
228 draw=none,
229 anchor=base west,
230 xshift=\scr_xoffset+\scr_xsep,
231 yshift=\scr_yoffset-\scr_boxht-\scr_corner-\scr_ysepsup,
232 text={%
233 \ifboolKV[\scrname]{print}
234 {\useKV[\scrname]{text color}}
235 {white}%
236 }
237 ]
238 (txt\number\scr_blocknum)
239 {\scr_currentstuff};
240 \ifboolKV[\scrname]{num blocks}
241 {\node[
242 at=(origin),
243 draw=none,
244 anchor=base east,
245 xshift=-\scr_numsep,
246 yshift=\scr_yoffset-\scr_boxht-\scr_corner-\scr_ysepsup
247 ]
248 (num)
249 {\scr_eearg\numblock{\number\scr_blocknum}};
250 }
251 {}%
252 \advance\scr_blocknum1
253 \advance\scr_yoffset\dimexpr-\scr_totht-\scr_ysepsup-\scr_ysepinf-\scr_corner-\scr_linewidth\relax
254 \gdef\scr_blockstop{1}%
255 }
256 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
257 % dessine un bloc de départ %
258 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
259 \def\scr_initblock#1#2{%
260 \def\scr_current_blockcolor{#1}%
261 \def\scr_currentstuff{%
262 \useKV[\scrname]{pre text}%
263 \_inpicturetrue
264 #2%
265 \scr_blockstrut
266 }%
267 \setbox\scr_box\hbox{%
268 \pgfinterruptpicture
269 \scr_currentstuff
270 \endpgfinterruptpicture
271 }%
272 \edef\scr_boxwd{\scr_maxdim(\wd\scr_box,\scr_xsep+\scr_initarclength+\scr_em)}%
273 \edef\scr_boxht{\the\ht\scr_box}%
274 \edef\scr_totht{\the\dimexpr\ht\scr_box+\dp\scr_box\relax}%
275 \draw[
276 draw={%
277 \ifboolKV[\scrname]{print}
278 {scr_linegray!\scr_contrast!black}
279 {#1dd}%
280 },
281 line width=\scr_linewidth,
282 rounded corners=0.4*\scr_ex*\scr_scale,
283 fill={%
284 \ifboolKV[\scrname]{print}
285 {\ifboolKV[\scrname]{fill blocks}
286 {scr_fillgray}
287 {none}%
288 }
289 {\scr_current_blockcolor}%
290 },
291 yshift=\scr_yoffset,
292 xshift=\scr_xoffset
293 ]
294 (0,0)to[out=\scr_initarcangle,in=180-\scr_initarcangle](\scr_xsep+\scr_initarclength,0)--(\scr_boxwd+2*\scr_xsep,0)% ligne sup
295 --++(0,-\scr_totht-\scr_ysepsup-\scr_ysepinf-\scr_corner)% ligne est
296 --++(-\scr_boxwd+\scr_corner*2-2*\scr_xsep+\scr_notch*1.66666,0)--++(-\scr_corner,-\scr_corner)--++(-\scr_notch,0)--++(-\scr_corner,\scr_corner)--++(-0.66666*\scr_notch,0)--cycle% ligne bas
297 node[
298 at=(origin),
299 draw=none,
300 anchor=base west,
301 xshift=\scr_xoffset+\scr_xsep,
302 yshift=\scr_yoffset-\scr_boxht-\scr_corner-\scr_ysepsup,
303 text={%
304 \ifboolKV[\scrname]{print}
305 {\useKV[\scrname]{text color}}
306 {white}%
307 }
308 ]
309 (txt\number\scr_blocknum)
310 {\scr_currentstuff};
311 \ifboolKV[\scrname]{num blocks}
312 {\node[
313 at=(origin),
314 draw=none,
315 anchor=base east,
316 xshift=-\scr_numsep,
317 yshift=\scr_yoffset-\scr_boxht-\scr_corner-\scr_ysepsup
318 ]
319 (num)
320 {\scr_eearg\numblock{\number\scr_blocknum}};}
321 {}%
322 \advance\scr_blocknum1
323 \advance\scr_yoffset\dimexpr-\scr_totht-\scr_ysepsup-\scr_ysepinf-\scr_corner\relax
324 \gdef\scr_blockstop{0}%
325 }
326
327 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
328 % dessine un bloc de définition %
329 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
330 \newcommand*\initmoreblocks[1]{%
331 \def\scr_currentstuff{%
332 \useKV[\scrname]{pre text}%
333 \_inpicturetrue
334 \def\scr_scale{1}% Bugfix 0.16
335 #1%
336 \scr_blockstrut
337 }%
338 \setbox\scr_box\hbox{%
339 \pgfinterruptpicture
340 \scr_currentstuff
341 \endpgfinterruptpicture
342 }%
343 \edef\scr_boxwd{\scr_maxdim(\wd\scr_box,\scr_minwd+\scr_em*2)}%
344 \edef\scr_boxht{\the\ht\scr_box}%
345 \edef\scr_totht{\the\dimexpr\ht\scr_box+\dp\scr_box\relax}%
346 \def\scr_current_blockcolor{scrmoreblocks}%
347 \draw[
348 draw={%
349 \ifboolKV[\scrname]{print}
350 {scr_linegray!\scr_contrast!black}
351 {\scr_current_blockcolor dd}%
352 },
353 fill={%
354 \ifboolKV[\scrname]{print}
355 {\ifboolKV[\scrname]{fill blocks}
356 {scr_fillgray}
357 {none}%
358 }
359 {\scr_current_blockcolor}%
360 },
361 yshift=\scr_yoffset,
362 xshift=\scr_xoffset,
363 rounded corners=0.4*\scr_ex*\scr_scale
364 ]
365 (0,-\scr_totht-\scr_ysepsup-\scr_ysepinf-\scr_corner)[rounded corners=2*\scr_ex*\scr_scale]--(0,0)--(\scr_boxwd+2*\scr_xsep,0)% ligne sup
366 [rounded corners=0.4*\scr_ex*\scr_scale]--++(0,-\scr_totht-\scr_ysepsup-\scr_ysepinf-\scr_corner)% ligne est
367 --++(-\scr_boxwd-2*\scr_xsep+\scr_corner*2+\scr_notch*1.66666,0)--++(-\scr_corner,-\scr_corner)--++(-\scr_notch,0)--++(-\scr_corner,\scr_corner)--++(-.66666*\scr_notch,0)% ligne sud
368 --cycle
369 node[
370 at=(origin),
371 draw=none,
372 anchor=base west,
373 xshift=\scr_xoffset+\scr_xsep,
374 yshift=\scr_yoffset-\scr_boxht-\scr_corner-\scr_ysepsup,
375 text={%
376 \ifboolKV[\scrname]{print}
377 {\useKV[\scrname]{text color}}
378 {white}%
379 }
380 ]
381 (txt\number\scr_blocknum)
382 {\scr_currentstuff};
383 \ifboolKV[\scrname]{num blocks}
384 {\node[
385 at=(origin),
386 draw=none,
387 anchor=base east,
388 xshift=-\scr_numsep,
389 yshift=\scr_yoffset-\scr_boxht-\scr_corner-\scr_ysepsup
390 ]
391 (num)
392 {\scr_eearg\numblock{\number\scr_blocknum}};%
393 }
394 {}%
395 \advance\scr_blocknum1
396 \advance\scr_yoffset\dimexpr-\scr_totht-\scr_ysepsup-\scr_ysepinf-\scr_corner\relax
397 \gdef\scr_blockstop{0}%
398 }
399 \newcommand*\scr_namemoreblocks[1]{%
400 \begin{tikzpicture}
401 \setscratch{num blocks=false}%
402 \scr_xoffset0pt \scr_yoffset\dimexpr\scr_corner+\scr_ysepsup\relax% bugfix 0.18
403 \definecolor{scrmoreblocks}{HTML}{ff4d6a}% choix couleur foncée pour tracé du bloc qui suit
404 \scr_normalblock{scrmoreblocks}{%
405 \definecolor{scrmoreblocks}{HTML}{ff6680}% rétablir couleur claire par défaut
406 #1%
407 }%
408 \end{tikzpicture}%
409 }%
410
411 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
412 % dessine un bloc de répétition ou test %
413 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
414 \def\scr_blockloop#1#2#3#4#5{% #1=texte #2=instructions sup #3=instructions inf #4=boucle infinie (1 ou 0) #5=fleche de répétition (1 ou 0)
415 \def\scr_current_blockcolor{scrcontrol}% BUGFIX 0.11
416 \edef\scr_blocminheight{\dimexpr\scr_loopblockheight+\scr_ysepinf+\scr_ysepsup+\scr_corner\relax}% hauteur minimale d'un bloc normal
417 \setbox\scr_box\hbox{%
418 \pgfinterruptpicture
419 \useKV[\scrname]{pre text}%
420 \_inpicturetrue
421 #1%
422 \scr_blockstrut
423 \endpgfinterruptpicture
424 }%
425 \scr_csedef{scr_txtloopwd\number\scr_loopnest}{\scr_maxdim(\wd\scr_box,\scr_minwd+\scr_corner*2+\scr_notch*2)}%
426 \scr_csedef{scr_txtloopht\number\scr_loopnest}{\the\ht\scr_box}%
427 \scr_csedef{scr_txtlooptotht\number\scr_loopnest}{\the\dimexpr\ht\scr_box+\dp\scr_box\relax}%
428 \scr_csedef{toploopx\number\scr_loopnest}{\the\scr_xoffset}% coordonnées du point nord-west
429 \scr_csedef{toploopy\number\scr_loopnest}{\the\scr_yoffset}%
430 \scr_csedef{blocnum\number\scr_loopnest}{\number\scr_blocknum}%
431 \advance\scr_xoffset\scr_loopblockwidth
432 \advance\scr_yoffset\dimexpr-\scr_corner-\scr_ysepsup-\csname scr_txtlooptotht\number\scr_loopnest\endcsname-\scr_ysepinf\relax
433 \ifboolKV[\scrname]{num blocks}
434 {\scr_csdef{scr_numblockif\number\scr_loopnest}{%
435 \node[
436 at=(origin),
437 draw=none,
438 anchor=base east,
439 xshift=-\scr_numsep,
440 yshift=\csname toploopy\number\scr_loopnest\endcsname-\csname scr_txtloopht\number\scr_loopnest\endcsname-\scr_corner-\scr_ysepsup
441 ]
442 (num)
443 {\scr_eeearg\numblock{\csname blocnum\number\scr_loopnest\endcsname}};%
444 }%
445 }
446 {\scr_cslet{scr_numblockif\number\scr_loopnest}\empty
447 }%
448 \advance\scr_loopnest1
449 \advance\scr_blocknum1
450 #2%
451 \advance\scr_loopnest-1
452 \scr_cslet{scr_blockstopif_\number\scr_loopnest}\scr_blockstop
453 \scr_csedef{bottomifx\number\scr_loopnest}{\the\scr_xoffset}%
454 \scr_csedef{bottomify\number\scr_loopnest}{\the\scr_yoffset}%
455 \ifcat\relax\detokenize{#3}\relax\else% si instruction #3
456 \advance\scr_yoffset\dimexpr-\scr_blocminheight\relax% épaisseur théorique de la branche "sinon"
457 \scr_csedef{blocelsenum\number\scr_loopnest}{\number\scr_blocknum}%
458 \ifboolKV[\scrname]{num blocks}
459 {\scr_csdef{scr_numblockelse\number\scr_loopnest}{%
460 \node[
461 at=(origin),
462 draw=none,
463 anchor=base east,
464 xshift=-\scr_numsep,
465 yshift=\csname bottomify\number\scr_loopnest\endcsname-\scr_loopblockheight-\scr_corner
466 ]
467 (num)
468 {\scr_eeearg\numblock{\csname blocelsenum\number\scr_loopnest\endcsname}};}%
469 }
470 {\scr_cslet{scr_numblockelse\number\scr_loopnest}\empty
471 }%
472 \advance\scr_loopnest1
473 \advance\scr_blocknum1
474 #3%
475 \advance\scr_loopnest-1
476 \scr_csedef{bottomelsex\number\scr_loopnest}{\the\scr_xoffset}%
477 \scr_csedef{bottomelsey\number\scr_loopnest}{\the\scr_yoffset}%
478 \fi
479 \advance\scr_yoffset by \dimexpr-\scr_blocminheight\relax% épaisseur de la branche du bas
480 \def\scr_current_blockcolor{scrcontrol}%
481 % ############## dessin du corps ##############
482 \edef\scr_current_linecolor{\ifboolKV[\scrname]{print}{scr_linegray!\scr_contrast!black}{\scr_current_blockcolor dd}}%
483 \draw[
484 draw=\scr_current_linecolor,
485 line width=\scr_linewidth,
486 rounded corners=0.4*\scr_ex*\scr_scale,
487 fill={%
488 \ifboolKV[\scrname]{print}
489 {\ifboolKV[\scrname]{fill blocks}
490 {scr_fillgray}
491 {none}%
492 }
493 {\scr_current_blockcolor}%
494 }
495 ]
496 (\csname toploopx\number\scr_loopnest\endcsname,\csname toploopy\number\scr_loopnest\endcsname)--++(0.66666*\scr_notch,0)--++(\scr_corner,-\scr_corner)--++(\scr_notch,0)--++(\scr_corner,\scr_corner)--++(\csname scr_txtloopwd\number\scr_loopnest\endcsname+2*\scr_xsep-\scr_corner*2-\scr_notch*1.66666,0)% ligne sup
497 --++(0,-\csname scr_txtlooptotht\number\scr_loopnest\endcsname-\scr_ysepsup-\scr_ysepinf-\scr_corner)% ligne est "|"
498 --++(-\csname scr_txtloopwd\number\scr_loopnest\endcsname-2*\scr_xsep+\scr_corner*2+\scr_notch*1.66666+\scr_loopblockwidth,0)--++(-\scr_corner,-\scr_corner)--++(-\scr_notch,0)--++(-\scr_corner,\scr_corner)--++(-\scr_notch*.66666,0)% ligne sud "--\__/---------"
499 --(\csname bottomifx\number\scr_loopnest\endcsname,\csname bottomify\number\scr_loopnest\endcsname)% descente gauche bloc "if"
500 \ifcat\relax\detokenize{#3}\relax\else% tracé de la branche du else
501 \ifnum\csname scr_blockstopif_\number\scr_loopnest\endcsname=1
502 --++(\csname scr_txtloopwd\number\scr_loopnest\endcsname+2*\scr_xsep-\scr_loopblockwidth,0)% ligne haut de la barre else "-----------------"
503 \else
504 --++(\scr_notch*0.66666,0)--++(\scr_corner,-\scr_corner)--++(\scr_notch,0)--++(\scr_corner,\scr_corner)--++(\csname scr_txtloopwd\number\scr_loopnest\endcsname+2*\scr_xsep-\scr_corner*2-\scr_notch*1.66666-\scr_loopblockwidth,0)% ligne haut de la barre else "--\__/---------"
505 \fi
506 --++(0,-\scr_loopblockheight-\scr_ysepsup-\scr_ysepinf-\scr_corner)% descente barre else
507 --++(-\csname scr_txtloopwd\number\scr_loopnest\endcsname-2*\scr_xsep+\scr_corner*2+\scr_notch*1.66666+\scr_loopblockwidth,0)--++(-\scr_corner,-\scr_corner)--++(-\scr_notch,0)--++(-\scr_corner,\scr_corner)--++(-.66666*\scr_notch,0)% ligne sud "/--\__/---------"
508 --(\csname bottomelsex\number\scr_loopnest\endcsname,\csname bottomelsey\number\scr_loopnest\endcsname)% descente gauche bloc "else"
509 \fi
510 \ifnum\scr_blockstop=1
511 --++(\csname scr_txtloopwd\number\scr_loopnest\endcsname+2*\scr_xsep-\scr_loopblockwidth,0)% ligne haut de la barre de fin "----------------"
512 \else
513 --++(.66666*\scr_notch,0)--++(\scr_corner,-\scr_corner)--++(\scr_notch,0)--++(\scr_corner,\scr_corner)--++(\csname scr_txtloopwd\number\scr_loopnest\endcsname+2*\scr_xsep-\scr_corner*2-\scr_notch*1.66666-\scr_loopblockwidth,0)% ligne haut de la barre de fin "--\__/---------"
514 \fi
515 --++(0,-\scr_loopblockheight-\scr_ysepsup-\scr_ysepinf-\scr_corner)% ligne Est "\ + | + /"
516 \ifnum#4=1 %infiniteloop
517 --++(-\csname scr_txtloopwd\number\scr_loopnest\endcsname-2*\scr_xsep,0)% ligne Sud "\---------------"
518 \else
519 --++(-\csname scr_txtloopwd\number\scr_loopnest\endcsname-2*\scr_xsep+\scr_corner*2+\scr_notch*1.66666,0)--++(-\scr_corner,-\scr_corner)--++(-\scr_notch,0)--++(-\scr_corner,\scr_corner)--++(-.66666*\scr_notch,0)% ligne Sud "\--\__/---------"
520 \fi
521 --cycle;% remontée tout en haut et cycle ## bugfix 0.14
522 \advance\scr_xoffset\dimexpr-\scr_loopblockwidth\relax
523 \csname scr_numblockif\number\scr_loopnest\endcsname% numérote ou pas le texte dans le bandeau du haut
524 \node[
525 at=(origin),
526 draw=none,
527 anchor=base west,
528 xshift=\csname toploopx\number\scr_loopnest\endcsname+\scr_xsep,
529 yshift=\csname toploopy\number\scr_loopnest\endcsname-\csname scr_txtloopht\number\scr_loopnest\endcsname-\scr_corner-\scr_ysepsup,
530 text={%
531 \ifboolKV[\scrname]{print}
532 {\useKV[\scrname]{text color}}
533 {white}%
534 }
535 ]
536 (txt\csname blocnum\number\scr_loopnest\endcsname)
537 {%
538 \useKV[\scrname]{pre text}%
539 \_inpicturetrue
540 #1%
541 \scr_blockstrut
542 };
543 \ifcat\relax\detokenize{#3}\relax\else
544 \node[
545 at=(origin),
546 draw=none,
547 anchor=base west,
548 xshift=\csname toploopx\number\scr_loopnest\endcsname+\scr_xsep,
549 yshift=\csname bottomify\number\scr_loopnest\endcsname-\scr_loopblockheight-\scr_corner,
550 text={%
551 \ifboolKV[\scrname]{print}
552 {\useKV[\scrname]{text color}}
553 {white}%
554 }
555 ]
556 (txt\csname blocelsenum\number\scr_loopnest\endcsname)
557 {%
558 \useKV[\scrname]{pre text}%
559 \useKV[\scrname]{else word}%
560 };
561 \csname scr_numblockelse\number\scr_loopnest\endcsname% numérotation bloc else ou pas
562 \fi
563 \ifnum#5=1 %fleche
564 \edef\scr_arrowcolor{\ifboolKV[\scrname]{print}{scr_flaggray}{scrcontrol}!80!black}% couleur ded l'ombre
565 \draw[
566 \scr_arrowcolor,
567 line width=1.5pt,
568 -{Triangle[length=\scr_scale*1.25ex,width=\scr_scale*1.5ex]},
569 rounded corners=1pt*\scr_scale
570 ]
571 (\scr_xoffset+\scr_xsep*2+\csname scr_txtloopwd\number\scr_loopnest\endcsname-\scr_ex*3.5+1pt,\scr_yoffset+\scr_linewidth+\scr_ysepinf-1.25pt)--++(\scr_loopblockheight,0)--++(0,\scr_loopblockheight+\scr_corner*0.5);
572 \edef\scr_arrowcolor{\ifboolKV[\scrname]{print}{scr_flaggray}{white}}% colmeur de la flèche
573 \draw[
574 \scr_arrowcolor,
575 line width=\scr_scale*1.5pt,
576 -{Triangle[length=\scr_scale*1.25ex,width=\scr_scale*1.5ex]},
577 rounded corners=1pt*\scr_scale
578 ]
579 (\scr_xoffset+\scr_xsep*2+\csname scr_txtloopwd\number\scr_loopnest\endcsname-\scr_ex*3.5,\scr_yoffset+\scr_linewidth+\scr_ysepinf)--++(\scr_loopblockheight,0)--++(0,\scr_loopblockheight+\scr_corner*0.5);
580 \fi
581 \xdef\scr_blockstop{\ifnum#4=1 1\else0\fi}%
582 }
583
584 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
585 % dessine un ovale %
586 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
587 \def\scr_ovalbox#1#2#3{% #1=selection (1) ou pas (0) #2=couleur remplissage et contour #3=texte
588 \begingroup
589 \ifnum\lastkern=\scr_ovalsentinel
590 \unkern
591 \kern-.66667ex\relax
592 \fi
593 \scr_setcolors
594 \def\scr_current_blockcolor{#2}%
595 \unless\ifdefined\scr_contrast% bugfix 0.11
596 \scr_normalizedec\scr_contrast contrast[0,100]%
597 \edef\scr_contrast{\number\numexpr100-\scr_contrast}%
598 \fi
599 \if_inpicture\def\scr_scale{1}\else\scr_normalizedec\scr_scale scale[0.2,5]\fi
600 \begin{tikzpicture}[
601 baseline=(x.base),
602 x=1ex,
603 y=1ex,
604 inner sep=0.1ex,% bugfix 0.19 : 0.25ex pour inner ysep donne un résultat étrange, on met 0.1ex pour les 2
605 line width={\the\dimexpr\useKV[\scrname]{line width}\relax},
606 scale=\scr_scale,
607 every node/.style={scale=\scr_scale}
608 ]
609 \node[
610 line width={\the\dimexpr\useKV[\scrname]{line width}\relax},
611 rounded rectangle,
612 draw={%
613 \ifboolKV[\scrname]{print}
614 {scr_linegray!\scr_contrast!black}
615 {#2dd}%
616 },
617 fill={%
618 \ifboolKV[\scrname]{print}
619 {\ifboolKV[\scrname]{fill blocks}
620 {scr_fillgray\if1#1!85!black\fi}
621 {none}%
622 }
623 {\scr_current_blockcolor\if1#1d\fi}%
624 },
625 text={%
626 \ifboolKV[\scrname]{print}
627 {\useKV[\scrname]{text color}}
628 {white}%
629 }
630 ]
631 (x)
632 {%
633 \useKV[\scrname]{pre text}\relax
634 \scr_ovalstrut
635 \kern\scr_ovalsentinel sp
636 \_inpicturetrue
637 #3%
638 \relax% pour contourner bug dans XeLaTeX
639 \if1#1% si triangle de sélection
640 \kern1ex
641 \scr_menuselectarrow
642 \fi
643 \ifnum\lastkern=\scr_ovalsentinel
644 \unkern\kern-.66667ex\relax
645 \fi
646 };%
647 \end{tikzpicture}%
648 \endgroup
649 \kern\scr_ovalsentinel sp
650 }
651 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
652 % dessine un triangle de sélection %
653 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
654 \def\scr_menuselectarrow{%
655 \tikz[
656 baseline=-1ex,
657 x=1.5ex,
658 y=1.5ex,
659 rounded corners=1.5pt*\scr_scale
660 ]
661 \draw[
662 fill=white,
663 draw={\ifboolKV[\scrname]{print}{scr_linegray}{\scr_current_blockcolor}}
664 ]
665 (0,0)--(1,0)--(0.5,-0.6)--cycle;%
666 }
667 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
668 % dessine un menu %
669 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
670 \newcommand*\selectmenu[1]{% #1=texte du menu (sera composé et suivi du triangle de sélection)
671 \if_inpicture\def\scr_scale{1}\else\scr_normalizedec\scr_scale scale[0.2,5]\fi
672 \begin{tikzpicture}[
673 anchor=base west,
674 baseline=(textmenu.base west),
675 outer sep=0pt,
676 inner sep=0pt,
677 minimum size=0pt,
678 scale=\scr_scale,
679 every node/.style={scale=\scr_scale}
680 ]
681 \node[
682 rectangle,
683 rounded corners=1.5pt*\scr_scale,
684 draw={%
685 \ifboolKV[\scrname]{print}
686 {scr_linegray}
687 {\scr_current_blockcolor dd}%
688 },
689 inner sep=0.2em,
690 fill={%
691 \ifboolKV[\scrname]{print}
692 {\ifboolKV[\scrname]{fill blocks}
693 {scr_fillgray!85!black}
694 {none}%
695 }
696 {\scr_current_blockcolor}%
697 },
698 text={%
699 \ifboolKV[\scrname]{print}
700 {\useKV[\scrname]{text color}}
701 {white}%
702 }
703 ]
704 (textmenu)
705 {%
706 \useKV[\scrname]{pre text}%
707 \_inpicturetrue
708 \hskip.33333em \ignorespaces% bugfix 0.19
709 #1%
710 \scr_ovalstrut
711 \hskip.6666em
712 \scr_menuselectarrow
713 };
714 \end{tikzpicture}%
715 }
716 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
717 % dessine un losange %
718 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
719 \def\scr_boolbox#1#2{% #1=couleur #2=texte
720 \begingroup
721 \scr_setcolors
722 \edef\scr_previouskern{\number\lastkern}%
723 \edef\scr_linewidth{\useKV[\scrname]{line width}}%
724 \edef\_{\the\dimexpr.53033\dimexpr \scr_linewidth\relax\relax}%
725 \def\scr_current_blockcolor{#1}%
726 \edef\scr_boolsep{\useKV[\scrname]{bool sep}}%
727 \if_inpicture\def\scr_scale{1}\else\scr_normalizedec\scr_scale scale[0.2,5]\fi
728 \begin{tikzpicture}[
729 inner sep=0pt,
730 outer sep=0pt,
731 minimum size=0pt,
732 baseline=(x.base),
733 line width=\scr_linewidth,
734 rounded corners=0pt,% BUGFIX 0.11
735 scale=\scr_scale,
736 every node/.style={scale=\scr_scale}
737 ]
738 \setbox\scr_box\hbox{%
739 \pgfinterruptpicture
740 \useKV[\scrname]{pre text}%
741 \scr_ovalstrut
742 \kern\scr_boolsentinel sp
743 \_inpicturetrue
744 \if_boolempty
745 \vrule width#2 height0pt depth0pt\relax
746 \else
747 #2%
748 \fi
749 \xdef\scr_endkern{\number\lastkern}%
750 \endpgfinterruptpicture
751 }%
752 \edef\scr_totheight{\the\dimexpr\ht\scr_box+\dp\scr_box\relax}\edef\scr_boxwd{\the\wd\scr_box}%
753 \edef\scr_retainedwd{\the\dimexpr\scr_boxwd+\_*2\ifnum\scr_endkern=\scr_boolsentinel\space-\scr_totheight/2+1.41421\dimexpr\scr_boolsep\relax\fi\relax}%
754 \draw[
755 draw=none,
756 use as bounding box
757 ]
758 (\ifnum\scr_previouskern=\scr_boolsentinel-\scr_boolsep*.41421\else -\scr_totheight/2\fi,-\scr_boolsep)rectangle(\scr_retainedwd+\scr_totheight/2,\scr_totheight+\scr_boolsep);%
759 \draw[
760 fill={%
761 \ifboolKV[\scrname]{print}
762 {\ifboolKV[\scrname]{fill blocks}
763 {scr_fillgray\if_boolempty!85!black\fi}
764 {none}%
765 }
766 {\scr_current_blockcolor}%
767 },
768 draw={%
769 \ifboolKV[\scrname]{print}
770 {scr_linegray}
771 {#1dd}%
772 }
773 ]
774 (\scr_boolsep,-\scr_boolsep)--++(\scr_retainedwd-\scr_boolsep*2,0)--++(\scr_totheight/2+\scr_boolsep,\scr_totheight/2+\scr_boolsep)--++(-\scr_totheight/2-\scr_boolsep,\scr_totheight/2+\scr_boolsep)--++(-\scr_retainedwd+\scr_boolsep*2,0)--++(-\scr_totheight/2-\scr_boolsep,-\scr_totheight/2-\scr_boolsep)--cycle;%
775 \node[
776 inner sep=0pt,
777 outer sep=0pt,
778 minimum size=0pt,
779 draw=none,
780 anchor=south west,
781 text={%
782 \ifboolKV[\scrname]{print}
783 {\useKV[\scrname]{text color}}
784 {white}%
785 }
786 ]
787 (x)
788 {%
789 \useKV[\scrname]{pre text}%
790 \scr_ovalstrut
791 \kern\_%
792 \kern\scr_boolsentinel sp
793 \_inpicturetrue
794 \if_boolempty
795 \vrule width#2 height0pt depth0pt\relax
796 \else
797 #2%
798 \fi
799 \kern\_%
800 };%
801 \end{tikzpicture}%
802 \endgroup
803 \_boolemptyfalse
804 \kern\scr_boolsentinel sp
805 }
806 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
807 % environnement scratch %
808 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
809 \definecolor{scrmove} {HTML}{4c97ff}%
810 \definecolor{scrmoved} {HTML}{4280d7}%
811 \definecolor{scrmovedd} {HTML}{3373cc}%
812 \definecolor{scrlook} {HTML}{9966ff}%
813 \definecolor{scrlookd} {HTML}{865cd3}%
814 \definecolor{scrlookdd} {HTML}{774dcb}%
815 \definecolor{scrsound} {HTML}{cf63cf}%
816 \definecolor{scrsoundd} {HTML}{c94fc9}%
817 \definecolor{scrsounddd} {HTML}{bd42bd}%
818 \definecolor{scrpen} {HTML}{0fbd8c}%
819 \definecolor{scrpend} {HTML}{0da57a}%
820 \definecolor{scrpendd} {HTML}{0b8e69}%
821 \definecolor{scrvariable} {HTML}{ff8c1a}%
822 \definecolor{scrvariabled} {HTML}{ff0000}% il n'existe pas d'ovale avec triangle sélection pour variable
823 \definecolor{scrvariabledd} {HTML}{db6e00}%
824 \definecolor{scrlist} {HTML}{ff661a}%
825 \definecolor{scrlistd} {HTML}{ff0000}% idem
826 \definecolor{scrlistdd} {HTML}{f2590d}%
827 \definecolor{screvent} {HTML}{ffbf00}%
828 \definecolor{screventd} {HTML}{e6ac00}%
829 \definecolor{screventdd} {HTML}{cc9900}%
830 \definecolor{greenflag} {HTML}{4cbf56}%
831 \definecolor{flagcontour} {HTML}{45993d}%
832 \definecolor{scrcontrol} {HTML}{ffab19}%
833 \definecolor{scrcontrold} {HTML}{ec9b13}%
834 \definecolor{scrcontroldd} {HTML}{d08a17}%
835 \definecolor{scrsensing} {HTML}{5cb1d6}%
836 \definecolor{scrsensingd} {HTML}{47a8d1}%
837 \definecolor{scrsensingdd} {HTML}{2e8eb8}%
838 \definecolor{scroperator} {HTML}{59c059}%
839 \definecolor{scroperatord} {HTML}{ff0000}% idem
840 \definecolor{scroperatordd} {HTML}{389438}%
841 \definecolor{scrmoreblocks} {HTML}{ff6680}%
842 \definecolor{scrmoreblocksd} {HTML}{ff4d6a}%
843 \definecolor{scrmoreblocksdd} {HTML}{ff3355}%
844 \definecolor{penline} {HTML}{595e73}%
845 \definecolor{penblue} {HTML}{4c8eea}%
846 \definecolor{penvline} {HTML}{0da57a}%
847 \definecolor{boolempty} {HTML}{cf8b17}% new 0.14
848 \definecolor{boolemptyd} {HTML}{cf8b17}% new 0.14
849 \definecolor{boolemptydd} {HTML}{cf8b17}% new 0.14
850
851 % Les réglages par défaut (modifiables avec \setdefaultscratch)
852 \setKVdefault[\scrname]{
853 pre text = \sffamily ,% choix de la police
854 else word = sinon ,% mot dans branche "else"
855 x sep = 0.33333em ,% séparation entre côtés droits et gauche du bloc et le texte
856 y sepsup = 3pt ,% séparation entre côté sup (insert) et haut texte
857 y sepinf = 5pt ,% séparation entre côté inf et bas texte
858 line width = .4pt ,% épaisseur des lignes de relief
859 loop width = 3ex ,% épaisseur de la barre verticale à gauche d'un bloc de boucle
860 loop height = 1.75ex ,% hauteur de la barre du else et la barre finale
861 corner = 0.66667ex ,% valeur du chanfrein
862 notch = 1em ,% longueur des encoches
863 scale = 1 ,% échelle du dessin
864 init arcangle = 30 ,% angle début et fin de l'arc
865 init arclength = 5em ,% longueur de l'arc
866 contrast = 20 ,% contraste des lignes de relief
867 print = false ,% impression noir et blanc ?
868 fill blocks = false ,% remplissage des blocks lorsque l'option "print" est vraie
869 fill gray = 0.85 ,% taux de gris pour le remplissage si fill blocks est vraie
870 text color = black ,% couleur du texte lorsque l'option "print" est vraie
871 flag gray = 0.33 ,% taux de gris pour le drapeau et la flèche de répétition lorsque l'option "print" est vraie
872 line gray = 0.4 ,% taux de gris pour les lignes lorsque l'option "print" est vraie
873 bool sep = 1.25pt ,% séparation entre les blocs booléens imbriqués
874 num blocks = false ,% numérotation des blocs
875 num sep = 3pt ,% séparation entre bord gauche et numérotation
876 num start = 1 ,% numéro de départ
877 baseline = 1 ,% alignement sur le 1er bloc (en partant du haut)
878 }
879
880 \newenvironment{scratch}[1][]
881 {\scr_ifempty{#1}{}{\setscratch{#1}}%
882 \sffamily
883 \edef\scr_ex{\the\dimexpr1ex\relax}% valeur d'1ex pour le tracé de la flèche
884 \edef\scr_em{\the\dimexpr1em\relax}%
885 \scr_normalizedim\scr_corner corner [\scr_ex/3,\scr_ex]%
886 \scr_normalizedim\scr_notch notch [\scr_em/3,\scr_em*3]%
887 \scr_normalizedec\scr_scale scale [0.2,5]% échelle
888 \scr_normalizedim\scr_xsep x sep [0pt,\scr_em]%
889 \scr_normalizedim\scr_ysepsup y sepsup [1pt,\scr_ex*3]%
890 \scr_normalizedim\scr_ysepinf y sepinf [1pt,\scr_ex*3]%
891 \scr_normalizedim\scr_linewidth line width [0pt,5pt]% épaisseur des lignes soumises à l'échelle
892 \scr_normalizedim\scr_loopblockwidth loop width [3pt,\scr_em*3]%
893 \scr_normalizedim\scr_loopblockheight loop height [3pt,\scr_ex*3]%
894 \scr_normalizedec\scr_initarcangle init arcangle [20,40]%
895 \scr_normalizedim\scr_initarclength init arclength [\scr_em*3,\scr_em*8]%
896 \scr_normalizedim\scr_numsep num sep [0pt,\scr_em*3/2]%
897 \scr_normalizedec\scr_contrast contrast [0,100]%
898 \edef\scr_contrast{\number\numexpr100-\scr_contrast}%
899 \edef\scr_minwd{\the\dimexpr\scr_corner*4+\scr_notch*3-\scr_xsep*2}%
900 \edef\scr_valign{\useKV[\scrname]{baseline}}%
901 \scr_blocknum\number\numexpr\useKV[\scrname]{num start}\relax\relax
902 \setbox\scr_box\hbox{\scr_blockstrut}\edef\scr_blockstruttotht{\the\dimexpr\ht\scr_box+\dp\scr_box\relax}% haut totale du strut
903 \def\turnleft{\turn_arrow{}}\def\turnright{\turn_arrow{xscale=-1}}%
904 \let\blockmove \scr_blockmove
905 \let\blocklook \scr_blocklook
906 \let\blocksound \scr_blocksound
907 \let\blocklist \scr_blocklist
908 \let\blockpen \scr_blockpen
909 \let\blockvariable \scr_blockvariable
910 \let\blockevent \scr_blockevent
911 \let\blockinit \scr_blockinit
912 \let\blockrepeat \scr_blockrepeat
913 \let\blockinfloop \scr_blockinfloop
914 \let\blockifelse \scr_blockifelse
915 \let\blockif \scr_blockif
916 \let\blockinitclone \scr_blockinitclone
917 \let\blockcontrol \scr_blockcontrol
918 \let\blocksensing \scr_blocksensing
919 \let\blockmoreblocks\scr_blockmoreblocks
920 \let\namemoreblocks \scr_namemoreblocks
921 \scr_xoffset0pt \scr_yoffset0pt
922 \catcode`\:12 \catcode`\;12 \catcode`\!12 \catcode`\?12 \catcode`\_12
923 \csname skv_\if c\expandafter\scr_firsttonil\scr_valign c\_nil first\else second\fi\endcsname
924 {%
925 \def\scr_scratchend{\egroup\egroup$}%
926 $\vcenter\bgroup\hbox\bgroup\begin{tikzpicture}[%
927 }
928 {%
929 \let\scr_scratchend\relax
930 \begin{tikzpicture}[
931 baseline=(txt\scr_valign.base),
932 }%
933 scale=\scr_scale,
934 every node/.style={scale=\scr_scale},
935 line width=\scr_linewidth,
936 inner sep=0pt,
937 outer sep=0pt,
938 minimum size=0pt,
939 line cap=round
940 ]
941 \_inpicturetrue
942 \node[shape=coordinate](origin){};% origine
943 }%
944 {%
945 \end{tikzpicture}%
946 \scr_scratchend
947 \_inpicturefalse% par pure sécurité
948 }
949
950 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
951 % menu mouvement %
952 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
953 \def\scr_blockmove{\scr_normalblock{scrmove}}
954 \newcommand*\ovalmove{%
955 \scr_ifstar
956 {\scr_ovalbox1{scrmove}}
957 {\scr_ovalbox0{scrmove}}%
958 }
959 \def\ovalnum#1{% #1=selection (1) ou pas (0) #2=couleur contour #3=texte
960 \begingroup
961 \ifnum\lastkern=\scr_ovalsentinel
962 \unkern
963 \kern-.66667ex\relax
964 \fi
965 \edef\scr_linewidth{\the\dimexpr\useKV[\scrname]{line width}\relax}%
966 \ifdefined\scr_current_blockcolor% bugfix 0.11
967 \edef\scr_current_blockcolor{\scr_current_blockcolor dd}%
968 \else
969 \def\scr_current_blockcolor{black}%
970 \fi
971 \if_inpicture\def\scr_scale{1}\else\scr_normalizedec\scr_scale scale[0.2,5]\fi
972 \begin{tikzpicture}[
973 baseline=(x.base),
974 x=1ex,
975 y=1ex,
976 inner ysep=0.25ex,
977 inner xsep=0.1ex,
978 line width=\scr_linewidth,
979 scale=\scr_scale,
980 every node/.style={scale=\scr_scale}
981 ]
982 \node[
983 line width=\scr_linewidth,
984 rounded rectangle,
985 draw={%
986 \ifboolKV[\scrname]{print}
987 {scr_linegray}
988 {\scr_current_blockcolor}%
989 },
990 fill=white,
991 text=black
992 ]
993 (x)
994 {%
995 \useKV[\scrname]{pre text}\relax
996 \scr_ovalstrut
997 \kern\scr_ovalsentinel sp
998 \_inpicturetrue
999 #1%
1000 \relax% pour contourner bug dans XeLaTeX
1001 \ifnum\lastkern=\scr_ovalsentinel\relax\expandafter\scr_execfirst\else\expandafter\scr_execsecond\fi
1002 {\unkern
1003 \kern-.66667ex\relax
1004 }
1005 {}%
1006 };%
1007 \end{tikzpicture}%
1008 \endgroup
1009 \kern\scr_ovalsentinel sp
1010 }
1011 \def\turn_arrow#1{%
1012 \tikz[baseline=.25ex,x=6.5ex,y=6.5ex,#1]
1013 \draw[-{Triangle[angle=45:0.5ex 0.5ex,flex]},line width=.3333ex](0,0) arc[start angle=-80,end angle=190,radius=1ex];%
1014 }
1015
1016 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1017 % menu apparence %
1018 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1019 \def\scr_blocklook{\scr_normalblock{scrlook}}
1020 \newcommand*\ovallook{%
1021 \scr_ifstar
1022 {\scr_ovalbox1{scrlook}}
1023 {\scr_ovalbox0{scrlook}}%
1024 }
1025
1026 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1027 % menu son %
1028 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1029 \def\scr_blocksound{\scr_normalblock{scrsound}}
1030 \newcommand*\ovalsound{%
1031 \scr_ifstar
1032 {\scr_ovalbox1{scrsound}}
1033 {\scr_ovalbox0{scrsound}}%
1034 }
1035
1036 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1037 % menu stylo %
1038 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1039 \newif\if_pen
1040 \def\scr_drawpen{% dessin du crayon
1041 \begin{tikzpicture}[
1042 rotate=45,
1043 rounded corners=.4pt*\scr_scale,
1044 line width=.5pt,
1045 x=5ex,
1046 y=5ex,
1047 radius=5ex,
1048 baseline=4.5,
1049 inner sep=0pt,
1050 outer sep=0pt
1051 ]
1052 \draw[
1053 penline,
1054 fill={%
1055 \ifboolKV[\scrname]{print}
1056 {scr_linegray}
1057 {penblue}%
1058 }
1059 ]
1060 (0,0)--(22:0.1)..controls(0.13,0.04)and(0.13,-0.04)..(-22:0.1)[sharp corners]--cycle;
1061 \draw[
1062 penline,
1063 fill=white,
1064 rounded corners=.2pt*\scr_scale
1065 ]
1066 (22:0.1)--(22:0.2)[rounded corners=0.05pt*\scr_scale]--(.56,.07492)..controls(.62,0.04)and(.62,-0.04)..(.56,-.07492)[rounded corners=2pt*\scr_scale]--(-22:.2)[rounded corners=0.05pt*\scr_scale]--(-22:0.1)..controls(0.13,-0.04)and(0.13,0.04)..(22:0.1);
1067 \draw[
1068 penline,
1069 fill={%
1070 \ifboolKV[\scrname]{print}
1071 {scr_linegray}
1072 {penblue}%
1073 },
1074 rounded corners=.2pt*\scr_scale
1075 ]
1076 (.56,.07492)--(.88,.07492)..controls(.92,0.04)and(.92,-0.04)..(0.88,-.07492)[sharp corners]--(.56,-.07492)..controls(.62,-0.04)and(.62,0.04)..cycle;
1077 \draw[penline](.84,0.07492)..controls(.7,.24)and(.58,0.02)..(.5,0.16);
1078 \filldraw[penline](.535,.17) circle [radius=1pt];
1079 \end{tikzpicture}%
1080 }%
1081 \def\scr_blockpen{\_pentrue\scr_normalblock{scrpen}}
1082 \newcommand*\ovalpen{%
1083 \scr_ifstar
1084 {\scr_ovalbox1{scrpen}}
1085 {\scr_ovalbox0{scrpen}}%
1086 }
1087 \newcommand*\pencolor[1]{% #1 est la couleur
1088 \begin{tikzpicture}[
1089 baseline=(x.base),
1090 x=1ex,
1091 y=1ex,
1092 inner ysep=0.25ex,
1093 inner xsep=0.1ex
1094 ]
1095 \node[
1096 fill=#1,
1097 draw=white,
1098 rounded rectangle
1099 ]
1100 (x)
1101 {\vrule height1.66667ex depth0.33333ex width0pt\hskip1em\hskip0pt};
1102 \end{tikzpicture}%
1103 }
1104
1105 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1106 % menu données %
1107 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1108 \def\scr_blockvariable{\scr_normalblock{scrvariable}}
1109 \def\scr_blocklist{\scr_normalblock{scrlist}}
1110 \newcommand*\ovalvariable{%
1111 \scr_ifstar
1112 {\PackageError\scrname{Starred macro \string\ovalvariable* has no sense}{}%
1113 \scr_ovalbox1{scrvariable}%
1114 }
1115 {\scr_ovalbox0{scrvariable}%
1116 }%
1117 }
1118 \newcommand*\ovallist{%
1119 \scr_ifstar
1120 {\PackageError\scrname{Starred macro \string\ovallist* has no sense}{}%
1121 \scr_ovalbox1{scrlist}%
1122 }
1123 {\scr_ovalbox0{scrlist}%
1124 }%
1125 }
1126 \newcommand*\boollist{\scr_boolbox{scrlist}}
1127 \newif\if_boolempty
1128 \_boolemptyfalse
1129 \newcommand*\boolempty[1][2em]{\_boolemptytrue\scr_boolbox{boolempty}{#1}}
1130 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1131 % menu événement %
1132 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1133 \def\scr_blockevent{\scr_normalblock{screvent}}
1134 \def\scr_blockinit{\scr_initblock{screvent}}
1135 \newcommand*\greenflag{%
1136 \kern0.2em\relax
1137 \begin{tikzpicture}[
1138 baseline=3pt,
1139 sharp corners,
1140 scale=0.4
1141 ]
1142 \scr_normalizedim\scr_linewidth line width[0pt,5pt]% bugfix 0.18
1143 \draw[
1144 line width=\scr_linewidth,
1145 draw={%
1146 \ifboolKV[\scrname]{print}
1147 {scr_flaggray}
1148 {flagcontour}%
1149 },
1150 fill={%
1151 \ifboolKV[\scrname]{print}
1152 {scr_flaggray!85!white}
1153 {greenflag}%
1154 }
1155 ]
1156 (0,0.95)..controls(.4,1.4) and (.7,.7)..(1,1)--(1,.4)..controls(.7,0.1)and(.4,.8)..(0,.4)--cycle;
1157 \filldraw[{\ifboolKV[\scrname]{print}{scr_flaggray}{flagcontour}}]
1158 (-.1,0)rectangle(0,1);
1159 \end{tikzpicture}%
1160 \kern0.2em\relax\space
1161 }
1162
1163 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1164 % menu contrôle %
1165 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1166 \def\scr_blockrepeat#1#2{\scr_blockloop{#1}{#2}{}01}
1167 \def\scr_blockinfloop#1#2{\scr_blockloop{#1}{#2}{}11}% 1= texte #2=instructions dans la boucle
1168 \def\scr_blockifelse#1#2#3{\scr_blockloop{#1}{#2}{#3}00}% 1= texte #2=instructions dans la boucle
1169 \def\scr_blockif#1#2{\scr_blockifelse{#1}{#2}{}}
1170 \def\scr_blockinitclone{\scr_initblock{scrcontrol}}
1171 \def\scr_blockcontrol{\scr_normalblock{scrcontrol}}
1172 \newcommand*\ovalcontrol{%
1173 \scr_ifstar
1174 {\scr_ovalbox1{scrcontrol}}
1175 {\scr_ovalbox0{scrcontrol}}%
1176 }
1177
1178 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1179 % menu capteur %
1180 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1181 \newcommand*\ovalsensing{%
1182 \scr_ifstar
1183 {\scr_ovalbox1{scrsensing}}
1184 {\scr_ovalbox0{scrsensing}}%
1185 }
1186 \def\scr_blocksensing{\scr_normalblock{scrsensing}}
1187 \newcommand*\boolsensing{\scr_boolbox{scrsensing}}
1188
1189 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1190 % menu opérateur %
1191 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1192 \newcommand*\ovaloperator{%
1193 \scr_ifstar
1194 {\PackageError\scrname{Starred macro \string\ovaloperator* has no sense}{}%
1195 \scr_ovalbox1{scroperator}%
1196 }
1197 {\scr_ovalbox0{scroperator}%
1198 }%
1199 }
1200 \newcommand*\booloperator{\scr_boolbox{scroperator}}
1201
1202 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1203 % menu ajouter bloc %
1204 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1205 \newcommand*\ovalmoreblocks{%
1206 \scr_ifstar
1207 {\PackageError\scrname{Starred macro \string\ovalomoreblocks* has no sense}{}%
1208 \scr_ovalbox1{scroperator}%
1209 }
1210 {\scr_ovalbox0{scrmoreblocks}%
1211 }%
1212 }%
1213 \def\scr_blockmoreblocks{\scr_normalblock{scrmoreblocks}}
1214 \newcommand*\boolmoreblocks{\scr_boolbox{scrmoreblocks}}% BUGFIX 0.11
1215 \scr_restorecatcode
1216 \endinput
1217
1218 Versions :
1219 _____________________________________________________________________________
1220 | Version | Date | Changements |
1221 |---------+------------+------------------------------------------------------|
1222 | 0.1 | 19/02/2019 | Première version |
1223 |---------+------------+------------------------------------------------------|
1224 | 0.11 | 10/03/2019 | * \scr_current_blockcolor est désormais défini dans |
1225 | | | \scr_blockloop |
1226 | | | * \boolmoreblocks n'est plus bugguée |
1227 |---------+------------+------------------------------------------------------|
1228 | 0.12 | 18/05/2019 | * bug corrigé dans \ovalnum |
1229 | | | * bug corrigé dans \scr_ovalbox |
1230 |---------+------------+------------------------------------------------------|
1231 | 0.13 | 01/07/2019 | * \relax ajoutés pour éviter le bug de XeLaTeX |
1232 | | | concernant \lastkern |
1233 |---------+------------+------------------------------------------------------|
1234 | 0.14 | 01/10/2019 | * gestion de l'échelle (via clé "scale") améliorée |
1235 | | | * hors de l'environnement, les ovales et les losanges|
1236 | | | sont affectés par la clé scale si elle est |
1237 | | | spécifiée via \setscratch |
1238 | | | * erreur de tracé corrigée dans \scr_blockloop |
1239 | | | * nouveau losange vide : \boolempty[<dimension>] |
1240 |---------+------------+------------------------------------------------------|
1241 | 0.15 | 05/03/2020 | * l'échelle n'était pas initialisée dans les blocs |
1242 | | | normaux |
1243 |---------+------------+------------------------------------------------------|
1244 | 0.16 | 20/03/2020 | * regression 0.15 --> l'échelle est désormais |
1245 | | | initialisée dans \initmoreblocks |
1246 |---------+------------+------------------------------------------------------|
1247 | 0.17 | 27/04/2020 | * 2 ou 3 modifs en rapport avec la v0.2 de simplekv |
1248 |---------+------------+------------------------------------------------------|
1249 | 0.18 | 03/09/2020 | * initialisation de \scr_yoffset et \scr_xoffset dans|
1250 | | | \scr_namemoreblocks |
1251 | | | * \scr_linewidth est désormais définie dans |
1252 | | | \greenflag |
1253 |---------+------------+------------------------------------------------------|
1254 | 0.19 | 06/02/2022 | * échelle initialisée dans les blocs normaux |
1255 | | | * espace de 0.3333em en début de texte \selectmenu |
1256 | | | * bug fix dans \scr_ovalbox : 0.1 de séparation |
1257 | | | * \scr_blockstop vaut 0 après \blockspace |
1258 | | | * encodage package UTF-8 |
1259 |---------+------------+------------------------------------------------------|