summaryrefslogtreecommitdiff
path: root/graphics/pgf/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/pgf/contrib')
-rw-r--r--graphics/pgf/contrib/nimsticks/README.md12
-rw-r--r--graphics/pgf/contrib/nimsticks/nimsticks.dtx8
-rw-r--r--graphics/pgf/contrib/nimsticks/nimsticks.pdfbin75196 -> 75983 bytes
-rw-r--r--graphics/pgf/contrib/tikzpackets/README27
-rw-r--r--graphics/pgf/contrib/tikzpackets/tikzPackets.pdfbin0 -> 65270 bytes
-rw-r--r--graphics/pgf/contrib/tikzpackets/tikzPackets.sty138
-rw-r--r--graphics/pgf/contrib/tikzpackets/tikzPackets.tex170
7 files changed, 351 insertions, 4 deletions
diff --git a/graphics/pgf/contrib/nimsticks/README.md b/graphics/pgf/contrib/nimsticks/README.md
index 7a295a2a75..28115c95ad 100644
--- a/graphics/pgf/contrib/nimsticks/README.md
+++ b/graphics/pgf/contrib/nimsticks/README.md
@@ -17,3 +17,15 @@ It does this by providing two commands:
## Licensing
This work may be distributed and/or modified under the conditions of the [MIT license](LICENSE.txt).
+
+## Changes
+
+### [1.0.1] - 2020-07-12
+
+- Fixed typo in usage example in documentation.
+
+### [1.0] - 2020-07-12
+
+- First working version of package
+- Added \drawnimstick and \nimgame using lcg for the random numbers so it works across LaTeX, LuaTeX and XeTeX
+- Added documentation
diff --git a/graphics/pgf/contrib/nimsticks/nimsticks.dtx b/graphics/pgf/contrib/nimsticks/nimsticks.dtx
index 088eeda5c2..cad291987e 100644
--- a/graphics/pgf/contrib/nimsticks/nimsticks.dtx
+++ b/graphics/pgf/contrib/nimsticks/nimsticks.dtx
@@ -35,7 +35,7 @@
%
%\section{Usage}
%
-%For example, the input \lstinline!\nimgame{3,5,4}! will produce output like this (precise look affected by random wobble in the sticks):
+%For example, the input \lstinline!\nimgame{5,3,4}! will produce output like this (precise look affected by random wobble in the sticks):
%
%\nimgame{5,3,4}
%
@@ -43,7 +43,7 @@
%
%It is likely the user will want to use \lstinline{\nimgame} and not \lstinline{\drawnimstick} directly, but the input \lstinline{\drawnimstick} will produce output like this (precise look affected by random wobble in the sticks): \drawnimstick
%
-%\lstinline{\nimgame} will happily work with one heap, so the input \lstinline!\nimgame{7}! will produce output like this (precise look affected by random wobble in the sticks):
+%\lstinline{\nimgame} will happily work with one heap, so for example the input \lstinline!\nimgame{7}! will produce output like this (precise look affected by random wobble in the sticks):
%
%\nimgame{7}
%
@@ -64,7 +64,7 @@
\usepackage{doc}
\usepackage{listings}
\lstset{basicstyle=\ttfamily\footnotesize,commentstyle=\color{white},language=TeX}
-\title{nimsticks}
+\title{nimsticks v1.0.1}
\author{Peter Rowlett}
\begin{document}
\maketitle
@@ -75,7 +75,7 @@
%\iffalse
%<*nimsticks>
-\ProvidesPackage{nimsticks}[2020/07/12 nimsticks 1.0]
+\ProvidesPackage{nimsticks}[2020/07/12 nimsticks 1.0.1]
\RequirePackage[first=-100,last=100,seed=0]{lcg}
\RequirePackage{tikz}
\@ifundefined{drawnimstick}{}
diff --git a/graphics/pgf/contrib/nimsticks/nimsticks.pdf b/graphics/pgf/contrib/nimsticks/nimsticks.pdf
index ea9bfc6000..34c70995cc 100644
--- a/graphics/pgf/contrib/nimsticks/nimsticks.pdf
+++ b/graphics/pgf/contrib/nimsticks/nimsticks.pdf
Binary files differ
diff --git a/graphics/pgf/contrib/tikzpackets/README b/graphics/pgf/contrib/tikzpackets/README
new file mode 100644
index 0000000000..9a98546311
--- /dev/null
+++ b/graphics/pgf/contrib/tikzpackets/README
@@ -0,0 +1,27 @@
+Package tikzPackets provide command for simple build network packets illustration with tikz.
+
+Usage example (UDP):
+
+\begin{tikzpicture}
+ \packetsInit
+ \packetsPrintBitScale{31}
+
+ \packetsPutField{16}{Source Port}
+ \packetsPutField{16}{Destination Port}
+ \packetsEndLine{0}{}
+
+ \packetsPutField{16}{Length}
+ \packetsPutField{16}{Checksum}
+ \packetsEndLine{32}{}
+
+ \packetsPutField[protocolsField, minimum height = 1.5cm]{32}{Data}
+ \packetsEndLine{64}{}
+\end{tikzpicture}
+
+
+Version 1.0 (2020-07-13): first public release
+
+
+Copyright (C) 2020, Robert Ryszard Paciorek <rrp@opcode.eu.org>
+
+This is free software distributed under terms of The MIT License.
diff --git a/graphics/pgf/contrib/tikzpackets/tikzPackets.pdf b/graphics/pgf/contrib/tikzpackets/tikzPackets.pdf
new file mode 100644
index 0000000000..7e311747d0
--- /dev/null
+++ b/graphics/pgf/contrib/tikzpackets/tikzPackets.pdf
Binary files differ
diff --git a/graphics/pgf/contrib/tikzpackets/tikzPackets.sty b/graphics/pgf/contrib/tikzpackets/tikzPackets.sty
new file mode 100644
index 0000000000..01c8546e3b
--- /dev/null
+++ b/graphics/pgf/contrib/tikzpackets/tikzPackets.sty
@@ -0,0 +1,138 @@
+% Copyright (c) 2020 Robert Ryszard Paciorek <rrp@opcode.eu.org>
+%
+% MIT License
+%
+% Permission is hereby granted, free of charge, to any person obtaining a copy
+% of this software and associated documentation files (the "Software"), to deal
+% in the Software without restriction, including without limitation the rights
+% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+% copies of the Software, and to permit persons to whom the Software is
+% furnished to do so, subject to the following conditions:
+%
+% The above copyright notice and this permission notice shall be included in all
+% copies or substantial portions of the Software.
+%
+% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+% SOFTWARE.
+
+% Version 1.0 (2020-07-13): first public release
+
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{tikzPackets}
+
+\RequirePackage{tikz}
+
+\RequirePackage{xparse}
+
+% need by \packetsPrintRangeOnRight:
+\ifdefined\tcbsetmacrotoheightofnode\else\RequirePackage[skins]{tcolorbox}\fi
+\RequirePackage{pbox}
+
+%
+% init counters, etc
+%
+
+\newdimen\packetsBitWidth\packetsBitWidth=5mm
+\newcounter{packets@FieldCounter}
+
+\newcommand{\packetsInit}{
+ \let\packetsFirstNodeInLastLine\undefined
+ \let\packets@ContinueLine\undefined
+ \setcounter{packets@FieldCounter}{0}
+ \newcommand{\packetsBitFont}{\tiny}
+ \packetsBitWidth=5mm
+ \tikzstyle{protocolsFieldBase}=[
+ anchor = north west, outer sep = 0pt % node position <=> position of left upper node corner
+ ]
+ \tikzstyle{protocolsField}=[
+ protocolsFieldBase,
+ draw, minimum height = 1cm,
+ ]
+ \tikzstyle{bitScaleInfo}=[
+ protocolsFieldBase, inner sep = 0pt,
+ minimum width = \packetsBitWidth, minimum height = 8pt,
+ node font=\packetsBitFont
+ ]
+}
+
+%
+% print bits numbering
+%
+
+
+\newcommand{\packetsPrintBitNumber}[1]{
+ \parbox[b][5pt]{\packetsBitWidth}{\hspace{1pt}#1}
+}
+
+\newcommand{\packetsPrintBitScale}[1]{
+ \node [bitScaleInfo] (bitScaleInfo_0) {\packetsPrintBitNumber{0}};
+ \foreach \n[remember=\n as \lastn (initially 0)] in {1,...,#1} {
+ \node [bitScaleInfo] (bitScaleInfo_\n) [] at (bitScaleInfo_\lastn.north east) {\packetsPrintBitNumber{\n}};
+ \draw[thin] (bitScaleInfo_\n.south west) |- (bitScaleInfo_\n.north west);
+ }
+ \draw (bitScaleInfo_0.south west) |- (bitScaleInfo_0.north west);
+ \draw (bitScaleInfo_#1.south east) |- (bitScaleInfo_#1.north east);
+
+ \def\packetsFirstNodeInLastLine{bitScaleInfo_0}
+ \def\packetsLastNode{bitScaleInfo_#1}
+}
+
+\newcommand{\packetsPrintRangeOnRight}[3][\packetsLastNode]{
+ \tcbsetmacrotoheightofnode{\packets@NodeHeight}{#1}
+ \node [anchor = south, outer sep = 2pt, inner sep = 0pt, rotate = -90, align=center, node font=\packetsBitFont] [] at (#1.east) {\pbox{\packets@NodeHeight}{#2-#3}};
+}
+
+\newcommand{\packetsPrintRangeOnLeft}[3][\packetsFirstNodeInLastLine]{
+ \node [anchor = east, outer sep = 2pt, inner sep = 0pt, align=center, node font=\packetsBitFont] [] at (#1.west) {#2};
+}
+
+%
+% add protocol fields
+%
+%\newcommand{\packetsPutField}[3][protocolsField]{
+\NewDocumentCommand{\packetsPutField}{ O{protocolsField} m o m } {
+ % if provide custom node name, use it
+ \IfValueTF {#3} {
+ \edef\packets@NewNodeName{#3}
+ }{
+ % otherwise get new node name and step counter
+ \edef\packets@NewNodeName{packetsFieldNode_\arabic{packets@FieldCounter}}
+ \stepcounter{packets@FieldCounter}
+ }
+
+ % if continue line
+ \ifdefined\packets@ContinueLine
+ \node[#1, minimum width=#2\packetsBitWidth] (\packets@NewNodeName) [] at (\packetsLastNode.north east) {#4};
+ % if start new line
+ \else
+ % if not first line
+ \ifdefined\packetsFirstNodeInLastLine
+ \node[#1, minimum width=#2\packetsBitWidth] (\packets@NewNodeName) [] at (\packetsFirstNodeInLastLine.south west) {#4};
+ \else
+ \node[#1, minimum width=#2\packetsBitWidth] (\packets@NewNodeName) {#4};
+ \fi
+ \let\packetsFirstNodeInLastLine\packets@NewNodeName
+ \def\packets@ContinueLine{true}
+ \fi
+
+ % remember new node name as \packetsLastNode
+ \let\packetsLastNode\packets@NewNodeName
+}
+
+%
+% finish line of fields
+%
+
+\newcommand{\packetsNextLine}{
+ \let\packets@ContinueLine\undefined
+}
+
+\newcommand{\packetsEndLine}[2]{
+ \packetsPrintRangeOnLeft{#1}{#2}
+ \packetsNextLine
+}
diff --git a/graphics/pgf/contrib/tikzpackets/tikzPackets.tex b/graphics/pgf/contrib/tikzpackets/tikzPackets.tex
new file mode 100644
index 0000000000..585550ebad
--- /dev/null
+++ b/graphics/pgf/contrib/tikzpackets/tikzPackets.tex
@@ -0,0 +1,170 @@
+% Copyright (c) 2020 Robert Ryszard Paciorek <rrp@opcode.eu.org>
+%
+% MIT License
+%
+% Permission is hereby granted, free of charge, to any person obtaining a copy
+% of this software and associated documentation files (the "Software"), to deal
+% in the Software without restriction, including without limitation the rights
+% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+% copies of the Software, and to permit persons to whom the Software is
+% furnished to do so, subject to the following conditions:
+%
+% The above copyright notice and this permission notice shall be included in all
+% copies or substantial portions of the Software.
+%
+% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+% SOFTWARE.
+
+\documentclass[a4paper]{article}
+
+\usepackage{tikzPackets}
+\usepackage{adjustbox,hyperref,fancyvrb-ex,fvextra}
+
+\oddsidemargin=0pt
+\textwidth=430pt
+
+\topmargin=-30pt
+\textheight=662pt
+
+\newcommand{\pkgLink}[1]{\texttt{\href{https://ctan.org/pkg/#1}{#1}}}
+
+\fvset{
+ breaklines=true,
+ breakanywhere=true,
+ breakaftersymbolpre={},
+ breakaftersymbolpost={\tiny\ensuremath{\ \lhook\joinrel\rightarrow\ }},
+ breakanywheresymbolpre={},
+ breakanywheresymbolpost={\tiny\ensuremath{\ \lhook\joinrel\rightarrow\ }}
+}
+
+\begin{document}
+
+\title{The \texttt{tikzPackets} package}
+\author{Robert Ryszard Paciorek <rrp@opcode.eu.org>}
+\date{2020-07-13}
+\maketitle
+
+This package provide command for simple build network packets illustration with \pkgLink{tikz}.
+Similar functionality (with tables instead of tikz) provide package \pkgLink{bytefield}.
+
+\section{Basic Example}
+
+\begin{CenterExample}
+\begin{tikzpicture}
+ \packetsInit
+ \packetsBitWidth=4.5mm
+ \packetsPrintBitScale{31}
+
+ \packetsPutField{16}{Source Port}
+ \packetsPutField{16}{Destination Port}
+ \packetsEndLine{0}{}
+
+ \packetsPutField{16}{Length}
+ \packetsPutField{16}{Checksum}
+ \packetsEndLine{32}{}
+
+ \packetsPutField[protocolsField, minimum height=1.5cm]{32}{Data}
+ \packetsEndLine{64}{}
+\end{tikzpicture}
+\end{CenterExample}
+
+
+\section{Macros description}
+
+\subsection{packetsInit}
+
+\Verb$\packetsInit$ is used to initialise \textit{tikzPackets} variables, counters and tikz styles.
+Must be used in every \Verb$tikzpicture$ that use \textit{tikzPackets} package commands before any other \textit{tikzPackets} command.
+
+\subsection{packetsPrintBitScale}
+
+\Verb$\packetsPrintBitScale$ draw bits scale. It takes one argument: last bit value.
+
+Formatting of bits scale can be adjust by redefine (after \Verb$\packetsInit$) tikz style \Verb$bitScaleInfo$, redefine \Verb$\packetsBitFont$ or \Verb$\packetsPrintBitNumber$ macro.
+
+\subsection{packetsPutField}
+
+\Verb$\packetsPutField$ draw packet field. It takes 4 arguments:
+\begin{enumerate}
+ \item (optional) node style and formatting options
+ \item number of bits (width of field)
+ \item (optional) node name for new created node
+ \item name (text to display)
+\end{enumerate}
+
+\subsection{packetsPrintRangeOnLeft and packetsPrintRangeOnRight}
+
+\Verb$\packetsPrintRangeOnLeft$ and \Verb$\packetsPrintRangeOnRight$ prints info (start bit number or bits range) on left or right side of current line.
+Should be call after call all \Verb$\packetsPutField$ for this line. Both commands takes two arguments: first bit in line and last bit in line,
+but \Verb$\packetsPrintRangeOnLeft$ ignore second argument.
+
+Formatting of printing text can be adjust by redefine \Verb$\packetsBitFont$ macro or redefine \Verb$\packetsPrintRangeOnLeft$ / \Verb$\packetsPrintRangeOnRight$ macros.
+
+\begin{CenterExample}
+\begin{tikzpicture}
+ \packetsInit
+ \renewcommand{\packetsBitFont}{\scriptsize}
+ \packetsPutField{4}{A} \packetsPutField{4}{B} \packetsPutField{4}{C}
+ \packetsPrintRangeOnLeft{a}{b}
+ \packetsPrintRangeOnRight{d}{e}
+\end{tikzpicture}
+\end{CenterExample}
+
+\subsection{packetsNextLine}
+
+\Verb$\packetsNextLine$ end current line of field and prepare to start next line of field. It don't have arguments.
+
+\subsection{packetsEndLine}
+
+\Verb$\packetsEndLine$ call \Verb$\packetsPrintRangeOnLeft$ and \Verb$\packetsNextLine$.
+Arguments are passed to \Verb$\packetsPrintRangeOnLeft$.
+
+\subsection{packetsLastNode and packetsFirstNodeInLastLine}
+
+\Verb$\packetsLastNode$ hold name of last added node by \Verb$\packetsPutField$ or \Verb$\packetsPrintBitScale$ (and is used for node positioning in \Verb$\packetsPutField$ and \Verb$\packetsPrintRangeOnRight$ macros).
+
+\Verb$\packetsFirstNodeInLastLine$ hold name of first node (added by macro \Verb$\packetsPutField$ or \Verb$\packetsPrintBitScale$) in current line (and is used in \Verb$\packetsPutField$ and \Verb$\packetsPrintRangeOnLeft$ for positioning)
+
+Both can be use for external to reference node adding by these macros (can be captured after add node by \Verb$\edef$) or can be used to start adding nodes by \Verb$\packetsPutField$ relative to some manually added node.
+
+\begin{CenterExample}
+\begin{tikzpicture}
+ \packetsInit
+ \packetsPutField{4}{A}
+ \packetsPutField{4}{B}
+
+ \node[
+ align=left, anchor=north west,
+ text width=7\packetsBitWidth, node font=\footnotesize
+ ] [] at (\packetsFirstNodeInLastLine.south west) {
+ Some extra info about this packet. And more more info \ldots
+ };
+\end{tikzpicture}
+\end{CenterExample}
+
+\section{Styles and dimmensions}
+
+Width of single bit is set by \Verb$\packetsBitWidth$ and default is 5mm. Default style for node created by \Verb$\packetsPutField$ is \Verb$protocolsField$ and it set line height to 1cm.
+Package provide also \Verb$protocolsFieldBase$ style with minimal setting for node style.
+Macro \Verb$\packetsBitFont$ define font settings for bits info.
+All this change should be done after use \Verb$\packetsInit$.
+
+\begin{CenterExample}
+\begin{tikzpicture}
+ \packetsInit
+ \tikzstyle{protocolsField}=[protocolsFieldBase, draw, minimum height = 0.8cm]
+ \packetsBitWidth=10mm
+ \renewcommand{\packetsBitFont}{\scriptsize\it}
+
+ \packetsPrintBitScale{7}
+ \packetsPutField{4}{Long field names}
+ \packetsPutField{4}{and low rows}
+\end{tikzpicture}
+\end{CenterExample}
+
+\end{document}