diff options
author | Karl Berry <karl@freefriends.org> | 2017-07-06 21:29:42 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2017-07-06 21:29:42 +0000 |
commit | 69b4ff04adcdeef7db32dd8a1a3c068e62d366a4 (patch) | |
tree | e8fb3a45fdb6cf6043619685efb96abc32ae4c6f /Master/texmf-dist/tex/latex/tikzcodeblocks | |
parent | c42ed950c46f42b713218d67e694ec05041734ba (diff) |
tikzcodeblocks (6jul17)
git-svn-id: svn://tug.org/texlive/trunk@44761 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/tikzcodeblocks')
-rw-r--r-- | Master/texmf-dist/tex/latex/tikzcodeblocks/tikzcodeblocks.sty | 591 |
1 files changed, 591 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/tikzcodeblocks/tikzcodeblocks.sty b/Master/texmf-dist/tex/latex/tikzcodeblocks/tikzcodeblocks.sty new file mode 100644 index 00000000000..de90a723a29 --- /dev/null +++ b/Master/texmf-dist/tex/latex/tikzcodeblocks/tikzcodeblocks.sty @@ -0,0 +1,591 @@ +% -*- coding: utf-8; -*- + +% CC-BY Adrian Salamon +% Bergische Universitaet Wuppertal +% 2017-07-06 + +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{tikzcodeblocks}[2016/07/04 TikZ Styles und Makros zum Setzen von graphischen Programmcodes, wie beim Calliopeeditor, NEPO oder Scratch] + +\RequirePackage{adjustbox} +\RequirePackage{xcolor} +\RequirePackage{colortbl} +\RequirePackage{fontawesome} +\RequirePackage{tikz} +\RequirePackage{longtable} +\usetikzlibrary{matrix, positioning, fit,calc,shapes,backgrounds,math,trees,decorations.markings,shapes,arrows.meta,arrows} +\usetikzlibrary{decorations,decorations.pathmorphing} + +\RequirePackage{xspace} + +\RequirePackage{ifthen} + +\newboolean{pxt-colors} +\setboolean{pxt-colors}{true} +\newboolean{nepo-colors} +\setboolean{nepo-colors}{false} + + +\DeclareOption{pxt}{ + \setboolean{pxt-colors}{true} +} +\DeclareOption{openroberta}{ + \setboolean{nepo-colors}{true} +} + + +\ExecuteOptions{pxt} %calliope colors are standard +\ProcessOptions\relax + + + + +% % % +% Variablen für Einzüge und Positonierungen +% % % + +% xshift= \einzug +% xshift= -\einzug +\newlength{\einzug} +\setlength{\einzug}{1em} +\newlength{\abstand} +\setlength{\abstand}{2pt} + + +\newboolean{keineinzug} +\setboolean{keineinzug}{true} +\newcommand{\einruecken}[1]{\setboolean{keineinzug}{false}#1\setboolean{keineinzug}{true}} + + +\ifthenelse{\boolean{nepo-colors}}{ +% % % +% Colordefinitions like lab.open-roberta.org +% % % +% +\definecolor{start-color}{HTML}{E2001A} +\definecolor{aktion-color}{HTML}{F29400} +\definecolor{sensoren-color}{HTML}{8FA402} +\definecolor{kontrolle-color}{HTML}{EB6A0A} +\definecolor{logik-color}{HTML}{33B8CA} +\definecolor{mathematik-color}{HTML}{005A94} +\definecolor{text-color}{HTML}{BACC1E} +\definecolor{listen-color}{HTML}{39378B} +\definecolor{farben-color}{HTML}{EBC300} +\definecolor{bilder-color}{HTML}{DF01D7} +\definecolor{variablen-color}{HTML}{9085BA} +\definecolor{funktionen-color}{HTML}{179C7D} +\definecolor{nachrichten-color}{HTML}{FF69B4} +% +\definecolor{int-color}{HTML}{005A94} +\definecolor{string-color}{HTML}{BACC1E} +\definecolor{boolean-color}{HTML}{33B8CA} +\definecolor{color-color}{HTML}{EBC300} +}{} + + + +\ifthenelse{\boolean{pxt-colors}}{ + % % % + % Colordefinitions like pxt.calliope.cc + % % % + % + \definecolor{grundlagen-color}{HTML}{54C9C9} + \definecolor{eingaben-color}{HTML}{C90072} + \definecolor{musik-color}{HTML}{DF4600} + \definecolor{led-color}{HTML}{8169E6} + \definecolor{schleifen-color}{HTML}{107C10} + \definecolor{logik-color}{HTML}{006970} + \definecolor{platzhalter-color}{HTML}{A80000} + \definecolor{mathematik-color}{HTML}{712672} + \definecolor{funk-color}{HTML}{E3008C} + \definecolor{motoren-color}{HTML}{008272} + \definecolor{text-color}{HTML}{996600} + \definecolor{spiel-color}{HTML}{008272} + \definecolor{bilder-color}{HTML}{5C2D91} + \definecolor{pins-color}{HTML}{A80000} + \definecolor{konsole-color}{HTML}{002050} + \definecolor{steuerung-color}{HTML}{42495F} + \definecolor{bluetooth-color}{HTML}{0082FB} + % + \definecolor{int-color}{HTML}{C6A8C7} + \definecolor{string-color}{HTML}{D6C299} + \definecolor{boolean-color}{HTML}{99C3C6} + \definecolor{color-color}{HTML}{BBE9E9} +}{} +% + + + + +\pgfdeclarelayer{background} +\pgfsetlayers{background,main} + + + +% % % +% Code-Block Objects +% % % + +\tikzset{ + codeblocks/.style = { + font = \ttfamily,rounded corners=2pt, rectangle,thick, + align=left, + node distance=6pt, + transform shape, % for scaling + anchor=base, baseline, + robertashape, + }, + eckig/.style ={rounded corners = 0pt, } +} + + +% +% Calliope-Nodes +% +\ifthenelse{\boolean{pxt-colors}}{ + \tikzset{ +% + grundlage/.style = {fill=grundlagen-color, text = white, draw = grundlagen-color!60!black, }, + eingabe/.style = {fill=eingaben-color, text = white, draw = eingaben-color!60!black, }, + schleife/.style = {fill=schleifen-color, text = white, draw = schleifen-color!60!black, }, + logik/.style = {fill=logik-color, text = white, draw = logik-color!60!black, }, + musik/.style = {fill=musik-color, text = white, draw = musik-color!60!black, }, + led/.style = {fill=led-color, text = white, draw = led-color!60!black, }, + platzhalter/.style = {fill=platzhalter-color, text = white, draw = platzhalter-color!60!black, }, + mathe/.style = {fill=mathematik-color, text = white, draw = mathematik-color!60!black, }, + funk/.style = {fill=funk-color, text = white, draw = funk-color!60!black, }, + motor/.style = {fill=motoren-color, text = white, draw = motoren-color!60!black, }, + zeichenkette/.style = {fill=text-color, text = white, draw = text-color!60!black, }, + spiel/.style = {fill=spiel-color, text = white, draw = spiel-color!60!black, }, + bild/.style = {fill=bilder-color, text = white, draw = bilder-color!60!black,align=left, }, + pins/.style = {fill=pins-color, text = white, draw = pins-color!60!black, }, + konsole/.style = {fill=konsole-color, text = white, draw = konsole-color!60!black, }, + 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 + aktion/.style = {grundlage}, + farbe/.style={grundlage}, + % + kontrolle/.style = {schleife}, + sensor/.style={pins}, + start/.style={grundlage}, + sensor/.style={eingabe}, + liste/.style={konsole}, + variablen/.style={platzhalter}, + nachricht/.style={bluetooth}, + funktion/.style={steuerung}, +} +}{} + + +% +% OpenRoberta-Nodes +% +% +\ifthenelse{\boolean{nepo-colors}}{ +% + \tikzset{ + % + 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,}, + 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,}, + 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,}, + 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,}, + % + %openroberta/.style = {rounded corners=0cm, }, + % 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}, +% } +} +}{} + + +% Allgemeine Styles +\tikzset{ + umgebung/.style = {draw,line width=2pt,transform shape=false}, % yshift ausgleich für die einzelnen elemente +% Bilder/Pictures/LED-Matrix + punktvoll/.style = {node distance = 1mm, circle,radius=2mm,fill=red, draw=black,opacity=1,draw}, + punktleer/.style = {node distance = 1mm, circle,radius=2mm,fill=white,opacity=0.7,draw=black,draw}, +% +% +% % % +% Boxes and smaller elements +% % % +% + dropdown/.style = { + fill=white, + draw=none, + opacity=0.7, % Leider auch Schriftsichtbarkeit + rectangle, + rounded corners=2pt, + inner sep=2pt, + anchor = base, + text = black, + text depth=0.50ex, + }, + intbox/.style = { + fill=int-color, + draw=none, + opacity=0.7, % Leider auch Schriftsichtbarkeit + rectangle, + rounded corners=2pt, + inner sep=3pt, + text = black, + anchor=west, + }, +% + stringbox/.style = { + fill=string-color, + draw=none, + opacity=0.7, % Leider auch Schriftsichtbarkeit + rectangle, + rounded corners=2pt, + inner sep=3pt, + text = black, + anchor=west, + }, + boolbox/.style = { + fill=boolean-color,boden + draw=none, + opacity=0.7, % Leider auch Schriftsichtbarkeit + rectangle, + rounded corners=2pt, + inner sep=3pt, + text = black, + anchor=west, + }, + boolbox/.style = { + fill=color-color, + draw=none, + opacity=0.7, % Leider auch Schriftsichtbarkeit + rectangle, + rounded corners=2pt, + inner sep=3pt, + text = black, + anchor=west, + }, +% Empty LEDs Help + ledanzeige/.style ={matrix of nodes, nodes = {punktleer},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 + }, + 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/.style n args={3}{below right = #3\abstand and #2\einzug of #1.south west}, +% +% https://tex.stackexchange.com/questions/223910/reference-a-nodes-color-by-using-node-name +% Farbe des 'aktuellen' Elementes bestimmen +every text node part/.add code={}{ + \globalcolorstrue + \ifx\tikz@fillcolor\pgfutil@empty + \pgfutil@colorlet{\tikz@fig@name.fill}{.} + \else + \pgfutil@colorlet{\tikz@fig@name.fill}{\tikz@fillcolor} + \fi + \ifx\tikz@strokecolor\pgfutil@empty + \pgfutil@colorlet{\tikz@fig@name.draw}{.} + \else + \pgfutil@colorlet{\tikz@fig@name.draw}{\tikz@strokecolor} + \fi + \ifx\tikz@textcolor\pgfutil@empty + \pgfutil@colorlet{\tikz@fig@name.text}{.} + \else + \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}}}{} + +% % % +% Makros für Boxen, LEDs, usw +% % % + +\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 + };\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 +} + +\newcommand{\setupquotes}{\normalfont \bfseries \color{white} } % vielleicht \huge ? + +\newcommand{\stringbox}[2][]{ + \begin{tikzpicture}[anchor=center,baseline=-4.0pt,] + \strut\node[stringbox,#1](string1){ + {\setupquotes ``}\,\tikz[boden]\strut\node[fill=white,rounded corners=2pt,opacity=1,keinezacken]{#2} + ;\setupquotes\,''}; + \end{tikzpicture} + +} + +\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} + ;}; +} + + +\newcommand{\bild}[2][1]{ + \scalebox{#1}[#1]{ + \tikz\matrix[ledanzeige] + { + #2 + }; + \hspace*{-16pt} % Ausgleich des zuvielen & + } +} + +\newcommand{\0}{|[punktleer]|\&} +\newcommand{\X}{|[punktvoll]|\&} + +\newcommand{\emptyled} +{ + \0 \0 \0 \0 \0 \\ + \0 \0 \0 \0 \0 \\ + \0 \0 \0 \0 \0 \\ + \0 \0 \0 \0 \0 \\ + \0 \0 \0 \0 \0 \\ +} + +\newcommand{\fullled} +{ + \X \X \X \X \X \\ + \X \X \X \X \X \\ + \X \X \X \X \X \\ + \X \X \X \X \X \\ + \X \X \X \X \X \\ +} + + +% +% Strukturen: Wenn-Dann/ Wenn-Dann-Sonst +% +\def\myspace{\vspace{5pt}} + +\newcommand{\wenndann}[4][]{ + \node[logik,#1](#4){% + % + \renewcommand{\arraystretch}{1} + \hspace*{-1em}\setboolean{keineinzug}{true} + \begin{tabular}{@{}ll} + Wenn \myspace\\%\hline + dann &\begin{tikzpicture}[anchor=north,yshift=0.95em ]#3\end{tikzpicture}\myspace\\[0.5em] + \end{tabular}}; +} + + +\newcommand{\wenndannsonst}[5][]{ + \node[logik,#1](#5){% + % + \renewcommand{\arraystretch}{1} + \hspace*{-1em}\setboolean{keineinzug}{true} + \begin{tabular}{@{}ll} + Wenn \myspace\\ %\hline + dann &\begin{tikzpicture}[anchor=north, yshift=0.95em ]#3\end{tikzpicture}\myspace\\ + sonst&\begin{tikzpicture}[anchor=north, yshift=0.95em ]#4\end{tikzpicture}\myspace\\ + \end{tabular}}; +} + +\newcommand{\schleife}[5][]{ + \node[kontrolle,#1](#5){\\ + \renewcommand{\arraystretch}{1} + \hspace*{-1em}\setboolean{keineinzug}{true} + \begin{tabular}{@{}ll} + #2 & #3\\[0,5em] + mache & \begin{tikzpicture}[anchor=north, yshift=0.95em]#4\end{tikzpicture}\\ + \end{tabular} + }; +} + + + + +\newcommand{\setzenippel}[1]{\foreach \i in {#1} + { + \begin{scope} + \draw[draw=none,rounded corners,fill=\i.fill]%!80!white,draw=none] + ($(\i.south west) + (1,0.4\einzug)$) -- ($(\i.south west) + (0.8,-0.4\einzug)$) -- ($(\i.south west) + (1.2,-0.4\einzug)$)--cycle; + \end{scope} +}} + +\newcommand{\setzepuzzle}[1]{\foreach \i in {#1} + { + \begin{scope} + \node[, fill=\i.fill%!60!white + ,rounded corners=2.5mm,circle, + ] + at ($(\i.west)+ (-0.05,0)$){}; + + \end{scope} +}} + + +% Lokale Farbdefinitonen erlauben +\newcommand{\setcolor}[2]{\definecolor{#1}{HTML}{#2}} + +% % +% +% Open Roberta Shapes mit Zacken oben und unten +% +% % + +\makeatletter +\pgfdeclareshape{robertashape} +{ + % This bit from \pgflibarayshapes.code.tex + \inheritsavedanchors[from=rectangle] + \inheritanchorborder[from=rectangle] + \inheritanchor[from=rectangle]{north} + \inheritanchor[from=rectangle]{north west} + \inheritanchor[from=rectangle]{north east} + \inheritanchor[from=rectangle]{center} + \inheritanchor[from=rectangle]{west} + \inheritanchor[from=rectangle]{east} + \inheritanchor[from=rectangle]{mid} + \inheritanchor[from=rectangle]{mid west} + \inheritanchor[from=rectangle]{mid east} + \inheritanchor[from=rectangle]{base} + \inheritanchor[from=rectangle]{base west} + \inheritanchor[from=rectangle]{base east} + \inheritanchor[from=rectangle]{south} + \inheritanchor[from=rectangle]{south west} + \inheritanchor[from=rectangle]{south east} + + \inheritbackgroundpath[from=rectangle] + \inheritbeforebackgroundpath[from=rectangle] + \inheritbehindforegroundpath[from=rectangle] + \inheritforegroundpath[from=rectangle] + \inheritbeforeforegroundpath[from=rectangle] + + \backgroundpath{ + % + \southwest \pgf@xa=\pgf@x \pgf@ya=\pgf@y + \northeast \pgf@xb=\pgf@x \pgf@yb=\pgf@y + + \xdef\einzugoben{1\einzug} + + \ifthenelse{\boolean{keineinzug}}{ % TODO Bedingungen verschönern? Aktuell globales boolean + \xdef\einzugunten{\einzugoben}}{ + \xdef\einzugunten{2*\einzugoben}} + + \def\dreieckseite{4} + + \pgfpathmoveto{\pgfpoint{\pgf@xa}{\pgf@ya}} %<-- south west + % + \pgfpathlineto{\pgfpoint{\pgf@xa+\einzugunten}{\pgf@ya}} + \pgfpathlineto{\pgfpoint{\pgf@xa+\einzugunten+\dreieckseite}{\pgf@ya-\dreieckseite}} %Spitze unten + \pgfpathlineto{\pgfpoint{\pgf@xa+\einzugunten+2*\dreieckseite}{\pgf@ya}} + % + \pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@ya}} % south east + \pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@yb}} % north east + % + \pgfpathlineto{\pgfpoint{\pgf@xa+\einzugoben+2*\dreieckseite}{\pgf@yb}} + \pgfpathlineto{\pgfpoint{\pgf@xa+\einzugoben+\dreieckseite}{\pgf@yb-\dreieckseite}} %Spitze oben + \pgfpathlineto{\pgfpoint{\pgf@xa+\einzugoben}{\pgf@yb}} + % + \pgfpathlineto{\pgfpoint{\pgf@xa}{\pgf@yb}} %<-- north west + \pgfpathclose + } + +} +\makeatother + + +% % +% +% puzzleteil Shapes mit Ausbuchtung links +% +% % + +\makeatletter +\pgfdeclareshape{puzzleteil} +{ + % This bit from \pgflibarayshapes.code.tex + \inheritsavedanchors[from=rectangle] + \inheritanchorborder[from=rectangle] + \inheritanchor[from=rectangle]{north} + \inheritanchor[from=rectangle]{north west} + \inheritanchor[from=rectangle]{north east} + \inheritanchor[from=rectangle]{center} + \inheritanchor[from=rectangle]{west} + \inheritanchor[from=rectangle]{east} + \inheritanchor[from=rectangle]{mid} + \inheritanchor[from=rectangle]{mid west} + \inheritanchor[from=rectangle]{mid east} + \inheritanchor[from=rectangle]{base} + \inheritanchor[from=rectangle]{base west} + \inheritanchor[from=rectangle]{base east} + \inheritanchor[from=rectangle]{south} + \inheritanchor[from=rectangle]{south west} + \inheritanchor[from=rectangle]{south east} + + \inheritbackgroundpath[from=rectangle] + \inheritbeforebackgroundpath[from=rectangle] + \inheritbehindforegroundpath[from=rectangle] + \inheritforegroundpath[from=rectangle] + \inheritbeforeforegroundpath[from=rectangle] + + \backgroundpath{ + % + \southwest \pgf@xa=\pgf@x \pgf@ya=\pgf@y + \northeast \pgf@xb=\pgf@x \pgf@yb=\pgf@y + + + \pgfpathmoveto{\pgfpoint{\pgf@xa}{\pgf@ya}} %<-- south west + \pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@ya}} % south east + \pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@yb}} % north east + \pgfpathlineto{\pgfpoint{\pgf@xa}{\pgf@yb}} %<-- north west + % Anpassung + \pgfpathlineto{\pgfpoint{\pgf@xa}{\pgf@yb-4pt}} + % + \pgfpathlineto{\pgfpoint{\pgf@xa-5pt}{\pgf@yb-2pt}} + \pgfpathlineto{\pgfpoint{\pgf@xa-5pt}{\pgf@yb-5pt}} + \pgfpathlineto{\pgfpoint{\pgf@xa-5pt}{\pgf@yb-13pt}} + \pgfpathlineto{\pgfpoint{\pgf@xa}{\pgf@yb-11pt}} + \pgfpathclose + } +} +\makeatother + + +% +% Farben +% +\newcommand{\farbe}[1]{\tikz\node[rectangle,minimum width=1em,minimum height = 1em,fill=#1]{};} + + +% +% Symbole +% +\newcommand{\usb}{\faUsb} |