diff options
author | Karl Berry <karl@freefriends.org> | 2018-04-03 21:30:09 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-04-03 21:30:09 +0000 |
commit | f096d42f822ea10711697547e80465f43e480e69 (patch) | |
tree | 25e30015b343ee60cacafbad946d0916fd5bbfce /Master/texmf-dist/tex/latex/tikzcodeblocks/tikzcodeblocks.sty | |
parent | 2b6fd1c0c7420f7afe24537ab44b1d387a093c43 (diff) |
tikzcodeblocks (3apr18)
git-svn-id: svn://tug.org/texlive/trunk@47265 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/tikzcodeblocks/tikzcodeblocks.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/tikzcodeblocks/tikzcodeblocks.sty | 358 |
1 files changed, 189 insertions, 169 deletions
diff --git a/Master/texmf-dist/tex/latex/tikzcodeblocks/tikzcodeblocks.sty b/Master/texmf-dist/tex/latex/tikzcodeblocks/tikzcodeblocks.sty index 05c9f6007e6..35dcd987e5b 100644 --- a/Master/texmf-dist/tex/latex/tikzcodeblocks/tikzcodeblocks.sty +++ b/Master/texmf-dist/tex/latex/tikzcodeblocks/tikzcodeblocks.sty @@ -2,11 +2,19 @@ % Adrian Salamon % Bergische Universitaet Wuppertal -% 2017-07-18 +% since 2017-09-23 +% to 2018-04-03 % LaTeX project public license, version 1.3c +% % notes for further development: +% +% TODO: Versionnummerierung fixen (evtl besseres) Konzept finden +% TODO: maybe remove LED-Background? +% +% % % + \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{tikzcodeblocks}[2016/07/18 v.0.11 - TikZ Styles and macros for typesetting blockwise graphic programming languages like scratch, nepo or pxt] +\ProvidesPackage{tikzcodeblocks}[2018/04/03 v.0.12 - TikZ Styles and macros for typesetting blockwise graphic programming languages like scratch, nepo or pxt] \RequirePackage{adjustbox} \RequirePackage{xcolor} @@ -56,7 +64,7 @@ % % % -% Variablen für Einzüge und Positonierungen +% Variables for intents and positioning % % % % xshift= \blockhspace @@ -97,11 +105,16 @@ \definecolor{string-color}{HTML}{D6C299} \definecolor{boolean-color}{HTML}{99C3C6} \definecolor{color-color}{HTML}{BBE9E9} + % Fallback LED-BG + \definecolor{led-bg-color}{HTML}{54C9C9} + \definecolor{led-on-color}{HTML}{F6F0A6} %das hier ist NEPO color \pgfdeclarelayer{background} \pgfsetlayers{background,main} +% allow local colordefinitions +\newcommand{\setcolor}[2]{\definecolor{#1}{HTML}{#2}} % % % @@ -147,7 +160,7 @@ steuerung/.style = {fill=steuerung-color, text = white, draw = steuerung-color!60!black, }, bluetooth/.style = {fill=bluetooth-color, text = white, draw = bluetooth-color!60!black, }, % - % Fallback styles / Für NEPO Kommandos + % Fallback styles / for NEPO commandos aktion/.style = {grundlage}, farbe/.style={grundlage}, % @@ -161,12 +174,12 @@ funktion/.style={steuerung}, } % -% % % PXT % % +% END PXT colors % % % % -% % OpenRoberta-Nodes % -% -% OpenRoberta Farben als Option setzbar: +% % START OpenRoberta-Nodes colors % % +% OpenRoberta Colors als package option: + \tikzset{ define color/.code 2 args={ \definecolor{#1}{HTML}{#2} @@ -183,6 +196,9 @@ openroberta/.style={ define color={listen-color}{39378B}, define color={farben-color}{EBC300}, define color={bilder-color}{DF01D7}, + define color={led-bg-color}{DF01D7}, + define color={led-on-color}{EDFEA0}, + define color={led-off-color}{F299EF}, define color={variablen-color}{9085BA}, define color={funktionen-color}{179C7D}, define color={nachrichten-color}{FF69B4}, @@ -194,44 +210,44 @@ openroberta/.style={ % start/.style = {fill=start-color, text = white, draw = start-color!60!black,}, aktion/.style = {fill=aktion-color, text = white, draw = aktion-color!60!black,}, - sensor/.style = {fill=sensoren-color, text = white, draw = sensoren-color!60!black,}, + sensor/.style = {fill=sensoren-color, text = white, draw = sensoren-color!60!black,}, kontrolle/.style = {fill=kontrolle-color, text = white, draw = kontrolle-color!60!black,}, logik/.style = {fill=logik-color, text = white, draw = logik-color!60!black,}, - mathe/.style = {fill=mathematik-color, text = white, draw = mathematik-color!60!black,}, - zeichenkette/.style = {fill=text-color, text = white, draw = text-color!60!black,}, + mathe/.style = {fill=mathematik-color, text = white, draw = mathematik-color!60!black,}, + zeichenkette/.style = {fill=text-color, text = white, draw = text-color!60!black,}, liste/.style = {fill=listen-color, text = white, draw = listen-color!60!black,}, - farbe/.style = {fill=farben-color, text = white, draw = farben-color!60!black,}, - bild/.style = {fill=bilder-color, text = white, draw = bilder-color!60!black,}, + farbe/.style = {fill=farben-color, text = white, draw = farben-color!60!black,}, + bild/.style = {fill=bilder-color, text = white, draw = bilder-color!60!black,}, variablen/.style = {fill=variablen-color, text = white, draw = variablen-color!60!black,}, - funktion/.style = {fill=funktionen-color, text = white, draw = funktionen-color!60!black,}, - nachricht/.style = {fill=nachrichten-color, text = white, draw = nachrichten-color!60!black,}, + funktion/.style = {fill=funktionen-color, text = white, draw = funktionen-color!60!black,}, + nachricht/.style = {fill=nachrichten-color, text = white, draw = nachrichten-color!60!black,}, % - % Fallback styles / Für PXT Kommandos - schleife/.style = {kontrolle}, - pins/.style={sensor}, - grundlage/.style={start}, - eingabe/.style={sensor}, - konsole/.style={liste}, - platzhalter/.style={variablen}, - bluetooth/.style={nachricht}, - steuerung/.style={funktion}, + % Fallback styles / for PXT commandos + schleife/.style = {kontrolle}, + pins/.style = {sensor}, + grundlage/.style = {start}, + eingabe/.style = {sensor}, + konsole/.style = {liste}, + platzhalter/.style= {variablen}, + bluetooth/.style = {nachricht}, + steuerung/.style = {funktion}, + ledOn/.style = {node distance = 1mm, circle,radius=2mm,fill=led-on-color, draw=black,opacity=1,draw}, %TODO Color fixen + ledOff/.style = {node distance = 1mm, circle,radius=2mm,fill=led-off-color, draw=black,opacity=1,draw}, %TODO Color fixen }%robertafarben }%tikzset - % % -% % % Open Roberta % % % % % +% % % ENDE Open Roberta % % % % % -% % Allgemeine Styles +% % global style definitions % \tikzset{ - umgebung/.style = {draw,line width=2pt,transform shape=false}, % yshift ausgleich für die einzelnen elemente -% Bilder/Pictures/LED-Matrix - ledOn/.style = {node distance = 1mm, circle,radius=2mm,fill=red, draw=black,opacity=1,draw}, - ledOff/.style = {node distance = 1mm, circle,radius=2mm,fill=white,opacity=0.7,draw=black,draw}, -% + umgebung/.style = {draw,line width=2pt,transform shape=false}, % yshift ausgleich for each element +% Pictures/LED-Matrix + ledOn/.style = {node distance = 1mm, circle, radius=2mm, fill=red, draw=black,opacity=1, draw}, + ledOff/.style = {node distance = 1mm, circle, radius=2mm, fill=white, draw=black,opacity=0.7, draw}, % % Boxes and smaller elements % @@ -256,7 +272,6 @@ openroberta/.style={ text = black, anchor=west, }, -% stringbox/.style = { fill=string-color, draw=none, @@ -277,24 +292,34 @@ openroberta/.style={ text = black, anchor=west, }, -% Empty LEDs Help - ledanzeige/.style ={matrix of nodes, nodes = {ledOff},row sep=4pt,column sep=4pt,ampersand replacement=\&, anchor=base}, % - boden/.style = {% Für Baseline anordnung der Dropdown - baseline,anchor=base, text height=1.7ex,text depth=0.3ex, minimum width=1em + ledanzeige/.style = {% LEDs Help + matrix of nodes, + row sep=4pt, + column sep=4pt, + ampersand replacement=\&, + anchor=base, fill=led-bg-color, + nopins }, - base/.style = { % Für Baseline anordnung der Dropdown - anchor=base, baseline +% + boden/.style = {% Für Baseline anordnung der Dropdown + baseline, + anchor=base, + text height=1.7ex, + text depth=0.3ex, + minimum width=1em }, - keinezacken/.style = { % Für Deaktivierung der OpenRobertaZacken - rectangle, -}, +% + base/.style = {% Für Baseline anordnung der Dropdown + anchor=base, baseline}, + keinezacken/.style = {% Für Deaktivierung der OpenRobertaZacken + rectangle}, % -% unter={NODENAME}{X--ABSTAND}{Y-ABSTAND} +% unter={NODENAME}{X-distance}{Y-distance} unter/.style n args={3}{below right = #3\blockvspace and #2\blockhspace of #1.south west}, % % https://tex.stackexchange.com/questions/223910/reference-a-nodes-color-by-using-node-name -% Farbe des 'aktuellen' Elementes bestimmen +% get color of 'this' element every text node part/.add code={}{ \globalcolorstrue \ifx\tikz@fillcolor\pgfutil@empty @@ -313,59 +338,60 @@ every text node part/.add code={}{ \pgfutil@colorlet{\tikz@fig@name.text}{\tikz@textcolor} \fi }, -} - -% Farbanpassung der Umgebung für OpenRoberta -%\ifthenelse{\boolean{nepo-colors}}{\tikzset{umgebung/.append style = {draw=white}}}{} +} %end tikzset % % % -% Makros für Boxen, LEDs, usw +% macros for boxes, LEDs, etc. % % % - \newcommand{\dropdown}[1]{\hspace*{-0.5em} - \tikz[boden]\node[dropdown]{#1\,\tikz[scale=0.3,baseline=-0.3em] \draw [fill,rounded corners=0mm,] (0,0)--(0.5,0)--(0.25,-0.5)--cycle;% Dreieck + \tikz[boden]\node[dropdown]{ + #1\,\tikz[scale=0.3,baseline=-0.3em] + \draw [fill,rounded corners=0mm,] + (0,0)--(0.5,0)--(0.25,-0.5)--cycle;% Dreieck };\hspace*{-0.5em} } \newcommand{\intbox}[2][]{ - \tikz[anchor=center,baseline=-4.0pt,]\strut\node[intbox,#1]{ - %\hspace*{-0.5em} - \tikz[boden]\strut\node[fill=white,rounded corners=6pt,opacity=1,keinezacken]{ - %\hspace*{-0.5em} - #2} - ;};\xspace + \tikz[anchor=center,baseline=-4.0pt,]\strut\node[intbox,#1,text width = {width("{#2}")+0.5em}]{ %this is tikz-magic... 1 + \tikz[boden]\strut\node[fill=white,rounded corners=6pt,opacity=1,keinezacken,text width = {width("{#2}")-0.0em} %this is tikz-magic... 2 + ]{ + #2}; + };\xspace } -\ifthenelse{\boolean{no-colors}} -{ - \newcommand{\setupquotes}{\normalfont \bfseries \huge \vspace*{1em}\color{black}} -} -{ - \newcommand{\setupquotes}{\normalfont \bfseries \huge \vspace*{1em}\color{white}} -} +% Fix for print option at stringboxes +\ifthenelse +{\boolean{no-colors}}% if +{\newcommand{\setupquotes}{\normalfont \bfseries \huge \vspace*{1em}\color{black}}}% then +{\newcommand{\setupquotes}{\normalfont \bfseries \huge \vspace*{1em}\color{white}}}% else +% box containing strings \newcommand{\stringbox}[2][]{ - \begin{tikzpicture}[anchor=center,baseline=-4.0pt,] - \strut\node[stringbox,#1](string1){ - {\setupquotes ``}\,\tikz[boden]\strut\node[yshift=0.5em,fill=white,rounded corners=2pt,opacity=1,keinezacken]{#2} + \begin{tikzpicture}[anchor=center,baseline=-4.0pt,] + \strut\node[stringbox,#1](string1){ + {\setupquotes ``}\,\tikz[boden]\strut\node[yshift=0.5em,fill=white,rounded corners=2pt,opacity=1,keinezacken]{#2} ;\setupquotes\,''\vspace*{-0.9em}}; \end{tikzpicture} - } +% box containing boolean \newcommand{\boolbox}[2][]{ \tikz[anchor=center,baseline=-4.0pt,]\strut\node[boolbox,#1]{ - \tikz[boden]\strut\node[fill=white,rounded corners=2pt,opacity=1,keinezacken]{#2} - ;}; + \tikz[boden]\strut\node[fill=white,rounded corners=2pt,opacity=1,keinezacken]{#2}; + }; } +% % % % % % % % +% Images / LEDs +% Bilder / LEDs + +% container for pictures \newcommand{\bild}[2][1]{ + \hspace*{-16pt} %macht es etwas kompakter \scalebox{#1}[#1]{ - \tikz\matrix[ledanzeige] - { - #2 - }; + \tikz\matrix[ledanzeige] %TODO: outer sep einfuegen/entfernen + {#2}; \hspace*{-16pt} % Ausgleich des zuvielen & } } @@ -373,6 +399,7 @@ every text node part/.add code={}{ \newcommand{\0}{|[ledOff]|\&} \newcommand{\X}{|[ledOn]|\&} +% template for all LEDs off \newcommand{\emptyled} { \0 \0 \0 \0 \0 \\ @@ -382,6 +409,7 @@ every text node part/.add code={}{ \0 \0 \0 \0 \0 \\ } +% template for all LEDs on \newcommand{\fullled} { \X \X \X \X \X \\ @@ -391,10 +419,13 @@ every text node part/.add code={}{ \X \X \X \X \X \\ } +% +% % % % % END images + +% % % % % % % % % Structures: Branches and Loops % Strukturen: Wenn-Dann/ Wenn-Dann-Sonst / Schleife -% \def\myspace{\vspace{5pt}} \def\myshift{0.95em} @@ -423,6 +454,7 @@ every text node part/.add code={}{ \end{tabular}}; } + \newcommand{\schleife}[5][]{ \node[kontrolle,#1](#5){\\ \renewcommand{\arraystretch}{1} @@ -434,18 +466,20 @@ every text node part/.add code={}{ }; } +% +% % % % % END structures -% Lokale Farbdefinitonen erlauben -\newcommand{\setcolor}[2]{\definecolor{#1}{HTML}{#2}} -% % Open Roberta Shapes mit Zacken oben und unten % % -% +% % % % % % % % +% Shapes +% Formen + +% Open Roberta Shapes with pins top and bottom % -\makeatletter \pgfdeclareshape{robertashape} { - % This bit from \pgflibarayshapes.code.tex + % This piece is from \pgflibarayshapes.code.tex \inheritsavedanchors[from=rectangle] \inheritanchorborder[from=rectangle] \inheritanchor[from=rectangle]{north} @@ -477,7 +511,7 @@ every text node part/.add code={}{ \xdef\blockhspaceoben{1\blockhspace} - \ifthenelse{\boolean{noIndentForPin}}{ % TODO Bedingungen verschönern? Aktuell globales boolean + \ifthenelse{\boolean{noIndentForPin}}{ % TODO Bedingungen verschönern? Aktuell globales boolean \xdef\blockhspaceunten{\blockhspaceoben}}{ \xdef\blockhspaceunten{2*\blockhspaceoben}} @@ -500,15 +534,12 @@ every text node part/.add code={}{ \pgfpathclose } } -\makeatother -% % Open Roberta Shapes mit Zacken NUR unten % % -% +% % Open Roberta Shapes with pins ONLY bottom % -\makeatletter \pgfdeclareshape{pinlow} { - % This bit from \pgflibarayshapes.code.tex + % This piece is from \pgflibarayshapes.code.tex \inheritsavedanchors[from=rectangle] \inheritanchorborder[from=rectangle] \inheritanchor[from=rectangle]{north} @@ -555,24 +586,17 @@ every text node part/.add code={}{ \pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@ya}} % south east \pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@yb}} % north east % - %\pgfpathlineto{\pgfpoint{\pgf@xa+\blockhspaceoben+2*\dreieckseite}{\pgf@yb}} - %\pgfpathlineto{\pgfpoint{\pgf@xa+\blockhspaceoben+\dreieckseite}{\pgf@yb-\dreieckseite}} %Spitze oben - %\pgfpathlineto{\pgfpoint{\pgf@xa+\blockhspaceoben}{\pgf@yb}} - % \pgfpathlineto{\pgfpoint{\pgf@xa}{\pgf@yb}} %<-- north west \pgfpathclose } } -\makeatother -% % Open Roberta Shapes mit Zacken NUR oben % % -% +% % Open Roberta Shapes with pins ONLY top % -\makeatletter \pgfdeclareshape{pinhigh} { - % This bit from \pgflibarayshapes.code.tex + % This piece from \pgflibarayshapes.code.tex \inheritsavedanchors[from=rectangle] \inheritanchorborder[from=rectangle] \inheritanchor[from=rectangle]{north} @@ -612,10 +636,6 @@ every text node part/.add code={}{ \pgfpathmoveto{\pgfpoint{\pgf@xa}{\pgf@ya}} %<-- south west % - %\pgfpathlineto{\pgfpoint{\pgf@xa+\blockhspaceunten}{\pgf@ya}} - %\pgfpathlineto{\pgfpoint{\pgf@xa+\blockhspaceunten+\dreieckseite}{\pgf@ya-\dreieckseite}} %Spitze unten - %\pgfpathlineto{\pgfpoint{\pgf@xa+\blockhspaceunten+2*\dreieckseite}{\pgf@ya}} - % \pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@ya}} % south east \pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@yb}} % north east % @@ -627,17 +647,14 @@ every text node part/.add code={}{ \pgfpathclose } } -\makeatother -% % puzzleteil Shapes mit Ausbuchtung links % +% % puzzlepiece Shapes mit hole at left side % -% -\makeatletter \pgfdeclareshape{puzzleteil} { - % This bit from \pgflibarayshapes.code.tex + % This piece is from \pgflibarayshapes.code.tex \inheritsavedanchors[from=rectangle] \inheritanchorborder[from=rectangle] \inheritanchor[from=rectangle]{north} @@ -682,81 +699,84 @@ every text node part/.add code={}{ \pgfpathclose } } -\makeatother + +% % % % % END shapes % % colors % +% print a small box with a certain color in it \newcommand{\farbe}[1]{\tikz\node[rectangle,minimum width=1em,minimum height = 1em,fill=#1]{};} - % % symbols % -\newcommand{\usb}{\faUsb} - - +\newcommand{\usb}{\faUsb} %USB-symbol % % Option: print (no-colors) % % % % TODO: Geht das mir einer Schleife? \ifthenelse{\boolean{no-colors}}{ -\tikzset{ -% -% pxt -% -grundlage/.append style={nocolor}, -eingabe/.append style={nocolor}, -schleife/.append style={nocolor}, -logik/.append style={nocolor}, -musik/.append style={nocolor}, -led/.append style={nocolor}, -platzhalter/.append style={nocolor}, -mathe/.append style={nocolor}, -funk/.append style={nocolor}, -motor/.append style={nocolor}, -zeichenkette/.append style={nocolor}, -spiel/.append style={nocolor}, -bild/.append style={nocolor}, -pins/.append style={nocolor}, -konsole/.append style={nocolor}, -steuerung/.append style={nocolor}, -bluetooth/.append style={nocolor}, -% -% openroberta -% -start/.append style={nocolor}, -aktion/.append style={nocolor}, -sensor/.append style={nocolor}, -kontrolle/.append style={nocolor}, -logik/.append style={nocolor}, -mathe/.append style={nocolor}, -zeichenkette/.append style={nocolor}, -liste/.append style={nocolor}, -farbe/.append style={nocolor}, -bild/.append style={nocolor}, -variablen/.append style={nocolor}, -funktion/.append style={nocolor}, -nachricht/.append style={nocolor}, -% -% Fallback styles / Für PXT Kommandos -schleife/.append style={nocolor}, -pins/.append style={nocolor}, -grundlage/.append style={nocolor}, -eingabe/.append style={nocolor}, -konsole/.append style={nocolor}, -platzhalte/.append style={nocolor}, -bluetooth/.append style={nocolor}, -steuerung/.append style={nocolor}, -% -% etc. -dropdown/.append style={fill=white, draw=black!60, opacity=1}, -ledOn/.append style={nocolor}, -intbox/.append style={nocolor}, -stringbox/.append style={nocolor}, -boolbox/.append style={nocolor}, -} +\tikzset + { + % + % pxt + % + grundlage/.append style={nocolor}, + eingabe/.append style={nocolor}, + schleife/.append style={nocolor}, + logik/.append style={nocolor}, + musik/.append style={nocolor}, + led/.append style={nocolor}, + platzhalter/.append style={nocolor}, + mathe/.append style={nocolor}, + funk/.append style={nocolor}, + motor/.append style={nocolor}, + zeichenkette/.append style={nocolor}, + spiel/.append style={nocolor}, + bild/.append style={nocolor}, + pins/.append style={nocolor}, + konsole/.append style={nocolor}, + steuerung/.append style={nocolor}, + bluetooth/.append style={nocolor}, + % + % openroberta + % + start/.append style={nocolor}, + aktion/.append style={nocolor}, + sensor/.append style={nocolor}, + kontrolle/.append style={nocolor}, + logik/.append style={nocolor}, + mathe/.append style={nocolor}, + zeichenkette/.append style={nocolor}, + liste/.append style={nocolor}, + farbe/.append style={nocolor}, + bild/.append style={nocolor}, + variablen/.append style={nocolor}, + funktion/.append style={nocolor}, + nachricht/.append style={nocolor}, + % + % Fallback styles / Für PXT Kommandos + schleife/.append style={nocolor}, + pins/.append style={nocolor}, + grundlage/.append style={nocolor}, + eingabe/.append style={nocolor}, + konsole/.append style={nocolor}, + platzhalte/.append style={nocolor}, + bluetooth/.append style={nocolor}, + steuerung/.append style={nocolor}, + % + % etc. + dropdown/.append style={fill=white, draw=black!60, opacity=1}, + ledOn/.append style={nocolor}, + ledOff/.append style={nocolor}, + intbox/.append style={nocolor}, + stringbox/.append style={nocolor}, + boolbox/.append style={nocolor}, + %TODO: Farben bei Openroberta LEDS entfernen + } }{} +% (local) Style print \tikzset{ print/.style={ % @@ -810,14 +830,14 @@ boolbox/.append style={nocolor}, dropdown/.append style={fill=white, draw=black!60, opacity=1}, ledOn/.append style={nocolor}, intbox/.append style={nocolor}, - stringbox/.append style={text-color=black, nocolor,}, % quotationmarks are still white... + stringbox/.append style={text-color=black, nocolor,}, % TODO: quotationmarks are still white... boolbox/.append style={nocolor}, + %TODO: Farben bei Openroberta LEDS entfernen } }% print -% % Redefine Commands for international usage % % -% +% % Redefine Commands for international usage ínto english language % % Controlstructures @@ -834,4 +854,4 @@ boolbox/.append style={nocolor}, square/.style={eckig}, nopins/.style={keinezacken}, puzzlepiece/.style={puzzleteil}, -}
\ No newline at end of file +} |