Debian Codegraph @

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

raw
1 % -*- coding: utf-8; -*-
2
3 % Adrian Salamon
4 % Bergische Universitaet Wuppertal
5 % since 2017-09-23
6 % to 2018-04-03
7 % LaTeX project public license, version 1.3c
8
9 % % notes for further development:
10 %
11 % TODO: Versionnummerierung fixen (evtl besseres) Konzept finden
12 % TODO: maybe remove LED-Background?
13 %
14 % % %
15
16 \NeedsTeXFormat{LaTeX2e}
17 \ProvidesPackage{tikzcodeblocks}[2018/04/03 v.0.12 - TikZ Styles and macros for typesetting blockwise graphic programming languages like scratch, nepo or pxt]
18
19 \RequirePackage{adjustbox}
20 \RequirePackage{xcolor}
21 \RequirePackage{colortbl}
22 \RequirePackage{fontawesome}
23 \RequirePackage{tikz}
24 \RequirePackage{longtable}
25 \usetikzlibrary{matrix, positioning, fit,calc,shapes,backgrounds,math,trees,decorations.markings,shapes,arrows.meta,arrows}
26 \usetikzlibrary{decorations,decorations.pathmorphing}
27
28 \RequirePackage{translations}
29
30 \RequirePackage{xspace}
31 \RequirePackage{ifthen}
32
33
34 \newboolean{no-colors}
35 \setboolean{no-colors}{false}
36
37 \DeclareOption{print}{
38 \setboolean{no-colors}{true}
39 }
40
41 \ProcessOptions\relax
42
43 % % %
44 % Translations
45 % % %
46
47 \DeclareTranslationFallback {if}{if}
48 \DeclareTranslation{English}{if}{if}
49 \DeclareTranslation{German} {if}{wenn}
50
51 \DeclareTranslationFallback {then}{then}
52 \DeclareTranslation{English}{then}{then}
53 \DeclareTranslation{German} {then}{dann}
54
55 \DeclareTranslationFallback {else}{else}
56 \DeclareTranslation{English}{else}{else}
57 \DeclareTranslation{German} {else}{sonst}
58
59 \DeclareTranslationFallback {do}{do}
60 \DeclareTranslation{English}{do}{do}
61 \DeclareTranslation{German} {do}{mache}
62
63
64
65
66 % % %
67 % Variables for intents and positioning
68 % % %
69
70 % xshift= \blockhspace
71 % xshift= -\blockhspace
72 \newlength{\blockhspace}
73 \setlength{\blockhspace}{1em}
74 \newlength{\blockvspace}
75 \setlength{\blockvspace}{2pt}
76
77
78 \newboolean{noIndentForPin}
79 \setboolean{noIndentForPin}{true}
80 \newcommand{\einruecken}[1]{\setboolean{noIndentForPin}{false}#1\setboolean{noIndentForPin}{true}}
81
82 % % %
83 % Colordefinitions like pxt.calliope.cc
84 % % %
85 %
86 \definecolor{grundlagen-color}{HTML}{54C9C9}
87 \definecolor{eingaben-color}{HTML}{C90072}
88 \definecolor{musik-color}{HTML}{DF4600}
89 \definecolor{led-color}{HTML}{8169E6}
90 \definecolor{schleifen-color}{HTML}{107C10}
91 \definecolor{logik-color}{HTML}{006970}
92 \definecolor{platzhalter-color}{HTML}{A80000}
93 \definecolor{mathematik-color}{HTML}{712672}
94 \definecolor{funk-color}{HTML}{E3008C}
95 \definecolor{motoren-color}{HTML}{008272}
96 \definecolor{text-color}{HTML}{996600}
97 \definecolor{spiel-color}{HTML}{008272}
98 \definecolor{bilder-color}{HTML}{5C2D91}
99 \definecolor{pins-color}{HTML}{A80000}
100 \definecolor{konsole-color}{HTML}{002050}
101 \definecolor{steuerung-color}{HTML}{42495F}
102 \definecolor{bluetooth-color}{HTML}{0082FB}
103 %
104 \definecolor{int-color}{HTML}{C6A8C7}
105 \definecolor{string-color}{HTML}{D6C299}
106 \definecolor{boolean-color}{HTML}{99C3C6}
107 \definecolor{color-color}{HTML}{BBE9E9}
108 % Fallback LED-BG
109 \definecolor{led-bg-color}{HTML}{54C9C9}
110 \definecolor{led-on-color}{HTML}{F6F0A6} %das hier ist NEPO color
111
112
113 \pgfdeclarelayer{background}
114 \pgfsetlayers{background,main}
115
116 % allow local colordefinitions
117 \newcommand{\setcolor}[2]{\definecolor{#1}{HTML}{#2}}
118
119
120 % % %
121 % Code-Block Objects
122 % % %
123
124 % global styles
125 \tikzset{
126 codeblocks/.style = {
127 font = \ttfamily,rounded corners=2pt, rectangle,thick,
128 align=left,
129 node distance=6pt,
130 transform shape, % for scaling
131 anchor=base, baseline,
132 robertashape,
133 },
134 eckig/.style ={rounded corners = 0pt},
135 nocolor/.style={fill=white, text = black, draw = black!60},
136 }
137
138 % % PXT-Nodes % %
139 %
140 %
141 % Colordefinitions like lab.open-roberta.org
142 %
143 \tikzset{
144 %
145 grundlage/.style = {fill=grundlagen-color, text = white, draw = grundlagen-color!60!black,},
146 eingabe/.style = {fill=eingaben-color, text = white, draw = eingaben-color!60!black, },
147 schleife/.style = {fill=schleifen-color, text = white, draw = schleifen-color!60!black, },
148 logik/.style = {fill=logik-color, text = white, draw = logik-color!60!black, },
149 musik/.style = {fill=musik-color, text = white, draw = musik-color!60!black, },
150 led/.style = {fill=led-color, text = white, draw = led-color!60!black, },
151 platzhalter/.style = {fill=platzhalter-color, text = white, draw = platzhalter-color!60!black, },
152 mathe/.style = {fill=mathematik-color, text = white, draw = mathematik-color!60!black, },
153 funk/.style = {fill=funk-color, text = white, draw = funk-color!60!black, },
154 motor/.style = {fill=motoren-color, text = white, draw = motoren-color!60!black, },
155 zeichenkette/.style = {fill=text-color, text = white, draw = text-color!60!black, },
156 spiel/.style = {fill=spiel-color, text = white, draw = spiel-color!60!black, },
157 bild/.style = {fill=bilder-color, text = white, draw = bilder-color!60!black,align=left, },
158 pins/.style = {fill=pins-color, text = white, draw = pins-color!60!black, },
159 konsole/.style = {fill=konsole-color, text = white, draw = konsole-color!60!black, },
160 steuerung/.style = {fill=steuerung-color, text = white, draw = steuerung-color!60!black, },
161 bluetooth/.style = {fill=bluetooth-color, text = white, draw = bluetooth-color!60!black, },
162 %
163 % Fallback styles / for NEPO commandos
164 aktion/.style = {grundlage},
165 farbe/.style={grundlage},
166 %
167 kontrolle/.style = {schleife},
168 sensor/.style={pins},
169 start/.style={grundlage},
170 sensor/.style={eingabe},
171 liste/.style={konsole},
172 variablen/.style={platzhalter},
173 nachricht/.style={bluetooth},
174 funktion/.style={steuerung},
175 }
176 %
177 % END PXT colors % % % %
178
179 % % START OpenRoberta-Nodes colors %
180 %
181 % OpenRoberta Colors als package option:
182
183 \tikzset{
184 define color/.code 2 args={
185 \definecolor{#1}{HTML}{#2}
186 },
187 openroberta/.style={
188 square, %keine Rundungen
189 define color={start-color}{E2001A},
190 define color={aktion-color}{F29400},
191 define color={sensoren-color}{8FA402},
192 define color={kontrolle-color}{EB6A0A},
193 define color={logik-color}{33B8CA},
194 define color={mathematik-color}{005A94},
195 define color={text-color}{BACC1E},
196 define color={listen-color}{39378B},
197 define color={farben-color}{EBC300},
198 define color={bilder-color}{DF01D7},
199 define color={led-bg-color}{DF01D7},
200 define color={led-on-color}{EDFEA0},
201 define color={led-off-color}{F299EF},
202 define color={variablen-color}{9085BA},
203 define color={funktionen-color}{179C7D},
204 define color={nachrichten-color}{FF69B4},
205 %
206 define color={int-color}{005A94},
207 define color={string-color}{BACC1E},
208 define color={boolean-color}{33B8CA},
209 define color={color-color}{EBC300},
210 %
211 start/.style = {fill=start-color, text = white, draw = start-color!60!black,},
212 aktion/.style = {fill=aktion-color, text = white, draw = aktion-color!60!black,},
213 sensor/.style = {fill=sensoren-color, text = white, draw = sensoren-color!60!black,},
214 kontrolle/.style = {fill=kontrolle-color, text = white, draw = kontrolle-color!60!black,},
215 logik/.style = {fill=logik-color, text = white, draw = logik-color!60!black,},
216 mathe/.style = {fill=mathematik-color, text = white, draw = mathematik-color!60!black,},
217 zeichenkette/.style = {fill=text-color, text = white, draw = text-color!60!black,},
218 liste/.style = {fill=listen-color, text = white, draw = listen-color!60!black,},
219 farbe/.style = {fill=farben-color, text = white, draw = farben-color!60!black,},
220 bild/.style = {fill=bilder-color, text = white, draw = bilder-color!60!black,},
221 variablen/.style = {fill=variablen-color, text = white, draw = variablen-color!60!black,},
222 funktion/.style = {fill=funktionen-color, text = white, draw = funktionen-color!60!black,},
223 nachricht/.style = {fill=nachrichten-color, text = white, draw = nachrichten-color!60!black,},
224 %
225 % Fallback styles / for PXT commandos
226 schleife/.style = {kontrolle},
227 pins/.style = {sensor},
228 grundlage/.style = {start},
229 eingabe/.style = {sensor},
230 konsole/.style = {liste},
231 platzhalter/.style= {variablen},
232 bluetooth/.style = {nachricht},
233 steuerung/.style = {funktion},
234 ledOn/.style = {node distance = 1mm, circle,radius=2mm,fill=led-on-color, draw=black,opacity=1,draw}, %TODO Color fixen
235 ledOff/.style = {node distance = 1mm, circle,radius=2mm,fill=led-off-color, draw=black,opacity=1,draw}, %TODO Color fixen
236 }%robertafarben
237 }%tikzset
238 %
239 %
240 % % % ENDE Open Roberta % % % % %
241
242
243
244 % % global style definitions
245 %
246 \tikzset{
247 umgebung/.style = {draw,line width=2pt,transform shape=false}, % yshift ausgleich for each element
248 % Pictures/LED-Matrix
249 ledOn/.style = {node distance = 1mm, circle, radius=2mm, fill=red, draw=black,opacity=1, draw},
250 ledOff/.style = {node distance = 1mm, circle, radius=2mm, fill=white, draw=black,opacity=0.7, draw},
251 %
252 % Boxes and smaller elements
253 %
254 dropdown/.style = {
255 fill=white,
256 draw=none,
257 opacity=0.7, % Leider auch Schriftsichtbarkeit
258 rectangle,
259 rounded corners=2pt,
260 inner sep=2pt,
261 anchor = base,
262 text = black,
263 text depth=0.50ex,
264 },
265 intbox/.style = {
266 fill=int-color,
267 draw=none,
268 opacity=0.7, % Leider auch Schriftsichtbarkeit
269 rectangle,
270 rounded corners=2pt,
271 inner sep=3pt,
272 text = black,
273 anchor=west,
274 },
275 stringbox/.style = {
276 fill=string-color,
277 draw=none,
278 opacity=0.7, % Leider auch Schriftsichtbarkeit
279 rectangle,
280 rounded corners=2pt,
281 inner sep=3pt,
282 text = black,
283 anchor=west,
284 },
285 boolbox/.style = {
286 fill=color-color,
287 draw=none,
288 opacity=0.7, % Leider auch Schriftsichtbarkeit
289 rectangle,
290 rounded corners=2pt,
291 inner sep=3pt,
292 text = black,
293 anchor=west,
294 },
295 %
296 ledanzeige/.style = {% LEDs Help
297 matrix of nodes,
298 row sep=4pt,
299 column sep=4pt,
300 ampersand replacement=\&,
301 anchor=base, fill=led-bg-color,
302 nopins
303 },
304 %
305 boden/.style = {% Für Baseline anordnung der Dropdown
306 baseline,
307 anchor=base,
308 text height=1.7ex,
309 text depth=0.3ex,
310 minimum width=1em
311 },
312 %
313 base/.style = {% Für Baseline anordnung der Dropdown
314 anchor=base, baseline},
315 keinezacken/.style = {% Für Deaktivierung der OpenRobertaZacken
316 rectangle},
317 %
318 % unter={NODENAME}{X-distance}{Y-distance}
319 unter/.style n args={3}{below right = #3\blockvspace and #2\blockhspace of #1.south west},
320 %
321 % https://tex.stackexchange.com/questions/223910/reference-a-nodes-color-by-using-node-name
322 % get color of 'this' element
323 every text node part/.add code={}{%
324 \globalcolorstrue%
325 \ifx\tikz@fillcolor\pgfutil@empty%
326 \pgfutil@colorlet{\tikz@[email protected]}{.}%
327 \else%
328 \pgfutil@colorlet{\tikz@[email protected]}{\tikz@fillcolor}%
329 \fi%
330 \ifx\tikz@strokecolor\pgfutil@empty%
331 \pgfutil@colorlet{\tikz@[email protected]}{.}%
332 \else%
333 \pgfutil@colorlet{\tikz@[email protected]}{\tikz@strokecolor}%
334 \fi%
335 \ifx\tikz@textcolor\pgfutil@empty%
336 \pgfutil@colorlet{\tikz@[email protected]}{.}%
337 \else%
338 \pgfutil@colorlet{\tikz@[email protected]}{\tikz@textcolor}%
339 \fi%
340 },
341 } %end tikzset
342
343 % % %
344 % macros for boxes, LEDs, etc.
345 % % %
346 \newcommand{\dropdown}[1]{\hspace*{-0.5em}
347 \tikz[boden]\node[dropdown]{
348 #1\,\tikz[scale=0.3,baseline=-0.3em]
349 \draw [fill,rounded corners=0mm,]
350 (0,0)--(0.5,0)--(0.25,-0.5)--cycle;% Dreieck
351 };\hspace*{-0.5em}
352 }
353
354 \newcommand{\intbox}[2][]{
355 \tikz[anchor=center,baseline=-4.0pt,]\strut\node[intbox,#1,text width = {width("{#2}")+0.5em}]{ %this is tikz-magic... 1
356 \tikz[boden]\strut\node[fill=white,rounded corners=6pt,opacity=1,keinezacken,text width = {width("{#2}")-0.0em} %this is tikz-magic... 2
357 ]{
358 #2};
359 };\xspace
360 }
361
362 % Fix for print option at stringboxes
363 \ifthenelse
364 {\boolean{no-colors}}% if
365 {\newcommand{\setupquotes}{\normalfont \bfseries \huge \vspace*{1em}\color{black}}}% then
366 {\newcommand{\setupquotes}{\normalfont \bfseries \huge \vspace*{1em}\color{white}}}% else
367
368 % box containing strings
369 \newcommand{\stringbox}[2][]{
370 \begin{tikzpicture}[anchor=center,baseline=-4.0pt,]
371 \strut\node[stringbox,#1](string1){
372 {\setupquotes ``}\,\tikz[boden]\strut\node[yshift=0.5em,fill=white,rounded corners=2pt,opacity=1,keinezacken]{#2}
373 ;\setupquotes\,''\vspace*{-0.9em}};
374 \end{tikzpicture}
375 }
376
377 % box containing boolean
378 \newcommand{\boolbox}[2][]{
379 \tikz[anchor=center,baseline=-4.0pt,]\strut\node[boolbox,#1]{
380 \tikz[boden]\strut\node[fill=white,rounded corners=2pt,opacity=1,keinezacken]{#2};
381 };
382 }
383
384
385 % % % % % % % %
386 % Images / LEDs
387 % Bilder / LEDs
388
389 % container for pictures
390 \newcommand{\bild}[2][1]{
391 \hspace*{-16pt} %macht es etwas kompakter
392 \scalebox{#1}[#1]{
393 \tikz\matrix[ledanzeige] %TODO: outer sep einfuegen/entfernen
394 {#2};
395 \hspace*{-16pt} % Ausgleich des zuvielen &
396 }
397 }
398
399 \newcommand{\0}{|[ledOff]|\&}
400 \newcommand{\X}{|[ledOn]|\&}
401
402 % template for all LEDs off
403 \newcommand{\emptyled}
404 {
405 \0 \0 \0 \0 \0 \\
406 \0 \0 \0 \0 \0 \\
407 \0 \0 \0 \0 \0 \\
408 \0 \0 \0 \0 \0 \\
409 \0 \0 \0 \0 \0 \\
410 }
411
412 % template for all LEDs on
413 \newcommand{\fullled}
414 {
415 \X \X \X \X \X \\
416 \X \X \X \X \X \\
417 \X \X \X \X \X \\
418 \X \X \X \X \X \\
419 \X \X \X \X \X \\
420 }
421
422 %
423 % % % % % END images
424
425
426 % % % % % % % %
427 % Structures: Branches and Loops
428 % Strukturen: Wenn-Dann/ Wenn-Dann-Sonst / Schleife
429
430 \def\myspace{\vspace{5pt}}
431 \def\myshift{0.95em}
432
433 \newcommand{\wenndann}[4][]{
434 \node[logik,#1](#4){%
435 %
436 \renewcommand{\arraystretch}{1}
437 \hspace*{-1em}\setboolean{noIndentForPin}{true}
438 \begin{tabular}{@{}ll}
439 \GetTranslation{if} &#2\myspace\\%\hline
440 \GetTranslation{then} &\begin{tikzpicture}[anchor=north,yshift=\myshift ]#3\end{tikzpicture}\myspace\\[0.5em]
441 \end{tabular}};
442 }
443
444
445 \newcommand{\wenndannsonst}[5][]{
446 \node[logik,#1](#5){%
447 %
448 \renewcommand{\arraystretch}{1}
449 \hspace*{-1em}\setboolean{noIndentForPin}{true}
450 \begin{tabular}{@{}ll}
451 \GetTranslation{if} &#2\myspace\\ %\hline
452 \GetTranslation{then} &\begin{tikzpicture}[anchor=north, yshift=\myshift ]#3\end{tikzpicture}\myspace\\
453 \GetTranslation{else}&\begin{tikzpicture}[anchor=north, yshift=\myshift ]#4\end{tikzpicture}\myspace\\
454 \end{tabular}};
455 }
456
457
458 \newcommand{\schleife}[5][]{
459 \node[kontrolle,#1](#5){\\
460 \renewcommand{\arraystretch}{1}
461 \hspace*{-1em}\setboolean{noIndentForPin}{true}
462 \begin{tabular}{@{}ll}
463 #2 & #3\\[0,5em]
464 \GetTranslation{do} & \begin{tikzpicture}[anchor=north, yshift=\myshift]#4\end{tikzpicture}\\
465 \end{tabular}
466 };
467 }
468
469 %
470 % % % % % END structures
471
472
473
474 % % % % % % % %
475 % Shapes
476 % Formen
477
478 % Open Roberta Shapes with pins top and bottom
479 %
480 \pgfdeclareshape{robertashape}
481 {
482 % This piece is from \pgflibarayshapes.code.tex
483 \inheritsavedanchors[from=rectangle]
484 \inheritanchorborder[from=rectangle]
485 \inheritanchor[from=rectangle]{north}
486 \inheritanchor[from=rectangle]{north west}
487 \inheritanchor[from=rectangle]{north east}
488 \inheritanchor[from=rectangle]{center}
489 \inheritanchor[from=rectangle]{west}
490 \inheritanchor[from=rectangle]{east}
491 \inheritanchor[from=rectangle]{mid}
492 \inheritanchor[from=rectangle]{mid west}
493 \inheritanchor[from=rectangle]{mid east}
494 \inheritanchor[from=rectangle]{base}
495 \inheritanchor[from=rectangle]{base west}
496 \inheritanchor[from=rectangle]{base east}
497 \inheritanchor[from=rectangle]{south}
498 \inheritanchor[from=rectangle]{south west}
499 \inheritanchor[from=rectangle]{south east}
500
501 \inheritbackgroundpath[from=rectangle]
502 \inheritbeforebackgroundpath[from=rectangle]
503 \inheritbehindforegroundpath[from=rectangle]
504 \inheritforegroundpath[from=rectangle]
505 \inheritbeforeforegroundpath[from=rectangle]
506
507 \backgroundpath{
508 %
509 \southwest \pgf@xa=\pgf@x \pgf@ya=\pgf@y
510 \northeast \pgf@xb=\pgf@x \pgf@yb=\pgf@y
511
512 \xdef\blockhspaceoben{1\blockhspace}
513
514 \ifthenelse{\boolean{noIndentForPin}}{ % TODO Bedingungen verschönern? Aktuell globales boolean
515 \xdef\blockhspaceunten{\blockhspaceoben}}{
516 \xdef\blockhspaceunten{2*\blockhspaceoben}}
517
518 \def\dreieckseite{4}
519
520 \pgfpathmoveto{\pgfpoint{\pgf@xa}{\pgf@ya}} %<-- south west
521 %
522 \pgfpathlineto{\pgfpoint{\pgf@xa+\blockhspaceunten}{\pgf@ya}}
523 \pgfpathlineto{\pgfpoint{\pgf@xa+\blockhspaceunten+\dreieckseite}{\pgf@ya-\dreieckseite}} %Spitze unten
524 \pgfpathlineto{\pgfpoint{\pgf@xa+\blockhspaceunten+2*\dreieckseite}{\pgf@ya}}
525 %
526 \pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@ya}} % south east
527 \pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@yb}} % north east
528 %
529 \pgfpathlineto{\pgfpoint{\pgf@xa+\blockhspaceoben+2*\dreieckseite}{\pgf@yb}}
530 \pgfpathlineto{\pgfpoint{\pgf@xa+\blockhspaceoben+\dreieckseite}{\pgf@yb-\dreieckseite}} %Spitze oben
531 \pgfpathlineto{\pgfpoint{\pgf@xa+\blockhspaceoben}{\pgf@yb}}
532 %
533 \pgfpathlineto{\pgfpoint{\pgf@xa}{\pgf@yb}} %<-- north west
534 \pgfpathclose
535 }
536 }
537
538 % % Open Roberta Shapes with pins ONLY bottom
539 %
540 \pgfdeclareshape{pinlow}
541 {
542 % This piece is from \pgflibarayshapes.code.tex
543 \inheritsavedanchors[from=rectangle]
544 \inheritanchorborder[from=rectangle]
545 \inheritanchor[from=rectangle]{north}
546 \inheritanchor[from=rectangle]{north west}
547 \inheritanchor[from=rectangle]{north east}
548 \inheritanchor[from=rectangle]{center}
549 \inheritanchor[from=rectangle]{west}
550 \inheritanchor[from=rectangle]{east}
551 \inheritanchor[from=rectangle]{mid}
552 \inheritanchor[from=rectangle]{mid west}
553 \inheritanchor[from=rectangle]{mid east}
554 \inheritanchor[from=rectangle]{base}
555 \inheritanchor[from=rectangle]{base west}
556 \inheritanchor[from=rectangle]{base east}
557 \inheritanchor[from=rectangle]{south}
558 \inheritanchor[from=rectangle]{south west}
559 \inheritanchor[from=rectangle]{south east}
560
561 \inheritbackgroundpath[from=rectangle]
562 \inheritbeforebackgroundpath[from=rectangle]
563 \inheritbehindforegroundpath[from=rectangle]
564 \inheritforegroundpath[from=rectangle]
565 \inheritbeforeforegroundpath[from=rectangle]
566
567 \backgroundpath{
568 %
569 \southwest \pgf@xa=\pgf@x \pgf@ya=\pgf@y
570 \northeast \pgf@xb=\pgf@x \pgf@yb=\pgf@y
571
572 \xdef\blockhspaceoben{1\blockhspace}
573
574 \ifthenelse{\boolean{noIndentForPin}}{ % TODO Bedingungen verschönern? Aktuell globales boolean
575 \xdef\blockhspaceunten{\blockhspaceoben}}{
576 \xdef\blockhspaceunten{2*\blockhspaceoben}}
577
578 \def\dreieckseite{4}
579
580 \pgfpathmoveto{\pgfpoint{\pgf@xa}{\pgf@ya}} %<-- south west
581 %
582 \pgfpathlineto{\pgfpoint{\pgf@xa+\blockhspaceunten}{\pgf@ya}}
583 \pgfpathlineto{\pgfpoint{\pgf@xa+\blockhspaceunten+\dreieckseite}{\pgf@ya-\dreieckseite}} %Spitze unten
584 \pgfpathlineto{\pgfpoint{\pgf@xa+\blockhspaceunten+2*\dreieckseite}{\pgf@ya}}
585 %
586 \pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@ya}} % south east
587 \pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@yb}} % north east
588 %
589 \pgfpathlineto{\pgfpoint{\pgf@xa}{\pgf@yb}} %<-- north west
590 \pgfpathclose
591 }
592 }
593
594
595 % % Open Roberta Shapes with pins ONLY top
596 %
597 \pgfdeclareshape{pinhigh}
598 {
599 % This piece from \pgflibarayshapes.code.tex
600 \inheritsavedanchors[from=rectangle]
601 \inheritanchorborder[from=rectangle]
602 \inheritanchor[from=rectangle]{north}
603 \inheritanchor[from=rectangle]{north west}
604 \inheritanchor[from=rectangle]{north east}
605 \inheritanchor[from=rectangle]{center}
606 \inheritanchor[from=rectangle]{west}
607 \inheritanchor[from=rectangle]{east}
608 \inheritanchor[from=rectangle]{mid}
609 \inheritanchor[from=rectangle]{mid west}
610 \inheritanchor[from=rectangle]{mid east}
611 \inheritanchor[from=rectangle]{base}
612 \inheritanchor[from=rectangle]{base west}
613 \inheritanchor[from=rectangle]{base east}
614 \inheritanchor[from=rectangle]{south}
615 \inheritanchor[from=rectangle]{south west}
616 \inheritanchor[from=rectangle]{south east}
617
618 \inheritbackgroundpath[from=rectangle]
619 \inheritbeforebackgroundpath[from=rectangle]
620 \inheritbehindforegroundpath[from=rectangle]
621 \inheritforegroundpath[from=rectangle]
622 \inheritbeforeforegroundpath[from=rectangle]
623
624 \backgroundpath{
625 %
626 \southwest \pgf@xa=\pgf@x \pgf@ya=\pgf@y
627 \northeast \pgf@xb=\pgf@x \pgf@yb=\pgf@y
628
629 \xdef\blockhspaceoben{1\blockhspace}
630
631 \ifthenelse{\boolean{noIndentForPin}}{ % TODO Bedingungen verschönern? Aktuell globales boolean
632 \xdef\blockhspaceunten{\blockhspaceoben}}{
633 \xdef\blockhspaceunten{2*\blockhspaceoben}}
634
635 \def\dreieckseite{4}
636
637 \pgfpathmoveto{\pgfpoint{\pgf@xa}{\pgf@ya}} %<-- south west
638 %
639 \pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@ya}} % south east
640 \pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@yb}} % north east
641 %
642 \pgfpathlineto{\pgfpoint{\pgf@xa+\blockhspaceoben+2*\dreieckseite}{\pgf@yb}}
643 \pgfpathlineto{\pgfpoint{\pgf@xa+\blockhspaceoben+\dreieckseite}{\pgf@yb-\dreieckseite}} %Spitze oben
644 \pgfpathlineto{\pgfpoint{\pgf@xa+\blockhspaceoben}{\pgf@yb}}
645 %
646 \pgfpathlineto{\pgfpoint{\pgf@xa}{\pgf@yb}} %<-- north west
647 \pgfpathclose
648 }
649 }
650
651
652
653 % % puzzlepiece Shapes mit hole at left side
654 %
655 \pgfdeclareshape{puzzleteil}
656 {
657 % This piece is from \pgflibarayshapes.code.tex
658 \inheritsavedanchors[from=rectangle]
659 \inheritanchorborder[from=rectangle]
660 \inheritanchor[from=rectangle]{north}
661 \inheritanchor[from=rectangle]{north west}
662 \inheritanchor[from=rectangle]{north east}
663 \inheritanchor[from=rectangle]{center}
664 \inheritanchor[from=rectangle]{west}
665 \inheritanchor[from=rectangle]{east}
666 \inheritanchor[from=rectangle]{mid}
667 \inheritanchor[from=rectangle]{mid west}
668 \inheritanchor[from=rectangle]{mid east}
669 \inheritanchor[from=rectangle]{base}
670 \inheritanchor[from=rectangle]{base west}
671 \inheritanchor[from=rectangle]{base east}
672 \inheritanchor[from=rectangle]{south}
673 \inheritanchor[from=rectangle]{south west}
674 \inheritanchor[from=rectangle]{south east}
675
676 \inheritbackgroundpath[from=rectangle]
677 \inheritbeforebackgroundpath[from=rectangle]
678 \inheritbehindforegroundpath[from=rectangle]
679 \inheritforegroundpath[from=rectangle]
680 \inheritbeforeforegroundpath[from=rectangle]
681
682 \backgroundpath{
683 %
684 \southwest \pgf@xa=\pgf@x \pgf@ya=\pgf@y
685 \northeast \pgf@xb=\pgf@x \pgf@yb=\pgf@y
686
687
688 \pgfpathmoveto{\pgfpoint{\pgf@xa}{\pgf@ya}} %<-- south west
689 \pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@ya}} % south east
690 \pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@yb}} % north east
691 \pgfpathlineto{\pgfpoint{\pgf@xa}{\pgf@yb}} %<-- north west
692 % Anpassung
693 \pgfpathlineto{\pgfpoint{\pgf@xa}{\pgf@yb-4pt}}
694 %
695 \pgfpathlineto{\pgfpoint{\pgf@xa-5pt}{\pgf@yb-2pt}}
696 \pgfpathlineto{\pgfpoint{\pgf@xa-5pt}{\pgf@yb-5pt}}
697 \pgfpathlineto{\pgfpoint{\pgf@xa-5pt}{\pgf@yb-13pt}}
698 \pgfpathlineto{\pgfpoint{\pgf@xa}{\pgf@yb-11pt}}
699 \pgfpathclose
700 }
701 }
702
703 % % % % % END shapes
704
705
706 % % colors
707 %
708 % print a small box with a certain color in it
709 \newcommand{\farbe}[1]{\tikz\node[rectangle,minimum width=1em,minimum height = 1em,fill=#1]{};}
710
711 % % symbols
712 %
713 \newcommand{\usb}{\faUsb} %USB-symbol
714
715 % % Option: print (no-colors) % %
716 %
717 % TODO: Geht das mir einer Schleife?
718 \ifthenelse{\boolean{no-colors}}{
719 \tikzset
720 {
721 %
722 % pxt
723 %
724 grundlage/.append style={nocolor},
725 eingabe/.append style={nocolor},
726 schleife/.append style={nocolor},
727 logik/.append style={nocolor},
728 musik/.append style={nocolor},
729 led/.append style={nocolor},
730 platzhalter/.append style={nocolor},
731 mathe/.append style={nocolor},
732 funk/.append style={nocolor},
733 motor/.append style={nocolor},
734 zeichenkette/.append style={nocolor},
735 spiel/.append style={nocolor},
736 bild/.append style={nocolor},
737 pins/.append style={nocolor},
738 konsole/.append style={nocolor},
739 steuerung/.append style={nocolor},
740 bluetooth/.append style={nocolor},
741 %
742 % openroberta
743 %
744 start/.append style={nocolor},
745 aktion/.append style={nocolor},
746 sensor/.append style={nocolor},
747 kontrolle/.append style={nocolor},
748 logik/.append style={nocolor},
749 mathe/.append style={nocolor},
750 zeichenkette/.append style={nocolor},
751 liste/.append style={nocolor},
752 farbe/.append style={nocolor},
753 bild/.append style={nocolor},
754 variablen/.append style={nocolor},
755 funktion/.append style={nocolor},
756 nachricht/.append style={nocolor},
757 %
758 % Fallback styles / Für PXT Kommandos
759 schleife/.append style={nocolor},
760 pins/.append style={nocolor},
761 grundlage/.append style={nocolor},
762 eingabe/.append style={nocolor},
763 konsole/.append style={nocolor},
764 platzhalte/.append style={nocolor},
765 bluetooth/.append style={nocolor},
766 steuerung/.append style={nocolor},
767 %
768 % etc.
769 dropdown/.append style={fill=white, draw=black!60, opacity=1},
770 ledOn/.append style={nocolor},
771 ledOff/.append style={nocolor},
772 intbox/.append style={nocolor},
773 stringbox/.append style={nocolor},
774 boolbox/.append style={nocolor},
775 %TODO: Farben bei Openroberta LEDS entfernen
776 }
777 }{}
778
779 % (local) Style print
780 \tikzset{
781 print/.style={
782 %
783 % pxt
784 %
785 grundlage/.append style={nocolor},
786 eingabe/.append style={nocolor},
787 schleife/.append style={nocolor},
788 logik/.append style={nocolor},
789 musik/.append style={nocolor},
790 led/.append style={nocolor},
791 platzhalter/.append style={nocolor},
792 mathe/.append style={nocolor},
793 funk/.append style={nocolor},
794 motor/.append style={nocolor},
795 zeichenkette/.append style={nocolor},
796 spiel/.append style={nocolor},
797 bild/.append style={nocolor},
798 pins/.append style={nocolor},
799 konsole/.append style={nocolor},
800 steuerung/.append style={nocolor},
801 bluetooth/.append style={nocolor},
802 %
803 % openroberta
804 %
805 start/.append style={nocolor},
806 aktion/.append style={nocolor},
807 sensor/.append style={nocolor},
808 kontrolle/.append style={nocolor},
809 logik/.append style={nocolor},
810 mathe/.append style={nocolor},
811 zeichenkette/.append style={nocolor},
812 liste/.append style={nocolor},
813 farbe/.append style={nocolor},
814 bild/.append style={nocolor},
815 variablen/.append style={nocolor},
816 funktion/.append style={nocolor},
817 nachricht/.append style={nocolor},
818 %
819 % Fallback styles / Für PXT Kommandos
820 schleife/.append style={nocolor},
821 pins/.append style={nocolor},
822 grundlage/.append style={nocolor},
823 eingabe/.append style={nocolor},
824 konsole/.append style={nocolor},
825 platzhalte/.append style={nocolor},
826 bluetooth/.append style={nocolor},
827 steuerung/.append style={nocolor},
828 %
829 % etc.
830 dropdown/.append style={fill=white, draw=black!60, opacity=1},
831 ledOn/.append style={nocolor},
832 intbox/.append style={nocolor},
833 stringbox/.append style={text-color=black, nocolor,}, % TODO: quotationmarks are still white...
834 boolbox/.append style={nocolor},
835 %TODO: Farben bei Openroberta LEDS entfernen
836 }
837 }% print
838
839
840 % % Redefine Commands for international usage ínto english language
841 %
842
843 % Controlstructures
844 \newcommand{\ifthenblocks}{\wenndann}
845 \newcommand{\ifthenelseblocks}{\wenndannsonst}
846 \newcommand{\loopblocks}{\schleife}
847
848 \newcommand{\moveindent}{\einruecken}
849
850 %styles:
851 \tikzset{
852 floor/.style={boden},
853 under/.style n args={3}{below right = #3\blockvspace and #2\blockhspace of #1.south west},
854 square/.style={eckig},
855 nopins/.style={keinezacken},
856 puzzlepiece/.style={puzzleteil},
857 }