summaryrefslogtreecommitdiff
path: root/graphics/pgf
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2022-07-22 03:00:41 +0000
committerNorbert Preining <norbert@preining.info>2022-07-22 03:00:41 +0000
commit72eecdf45fcf3f421668c6bdfbfe17141ce3edc1 (patch)
treef778bfd78287e84e9ef7a15580b97ed81e837944 /graphics/pgf
parent5cf5182b44c08dfb2bc977ce5aa5ca6d03b36923 (diff)
CTAN sync 202207220300
Diffstat (limited to 'graphics/pgf')
-rw-r--r--graphics/pgf/contrib/tikzbricks/README.md4
-rw-r--r--graphics/pgf/contrib/tikzbricks/tikzbricks-doc.pdfbin259649 -> 271210 bytes
-rw-r--r--graphics/pgf/contrib/tikzbricks/tikzbricks-doc.tex67
-rw-r--r--graphics/pgf/contrib/tikzbricks/tikzbricks.sty130
4 files changed, 155 insertions, 46 deletions
diff --git a/graphics/pgf/contrib/tikzbricks/README.md b/graphics/pgf/contrib/tikzbricks/README.md
index 93029705e2..8cd336a7c3 100644
--- a/graphics/pgf/contrib/tikzbricks/README.md
+++ b/graphics/pgf/contrib/tikzbricks/README.md
@@ -2,7 +2,9 @@
A small LaTeX package to draw bricks with TikZ. The user can modify the colour, shape and viewpoint.
-![example image of three bricks](https://raw.githubusercontent.com/samcarter/TikZbricks/main/showcase.svg)
+Current version: 2022/07/21 version v0.4
+
+![example image of three bricks](https://raw.githubusercontent.com/samcarter/TikZbricks/main/showcase/showcase.svg)
This project is licensed under the LaTeX Project Public License v1.3c or later, see http://www.latex-project.org/lppl.txt
diff --git a/graphics/pgf/contrib/tikzbricks/tikzbricks-doc.pdf b/graphics/pgf/contrib/tikzbricks/tikzbricks-doc.pdf
index 99f44e65ca..0b39ca2b61 100644
--- a/graphics/pgf/contrib/tikzbricks/tikzbricks-doc.pdf
+++ b/graphics/pgf/contrib/tikzbricks/tikzbricks-doc.pdf
Binary files differ
diff --git a/graphics/pgf/contrib/tikzbricks/tikzbricks-doc.tex b/graphics/pgf/contrib/tikzbricks/tikzbricks-doc.tex
index 401ec1a20d..febcba5c36 100644
--- a/graphics/pgf/contrib/tikzbricks/tikzbricks-doc.tex
+++ b/graphics/pgf/contrib/tikzbricks/tikzbricks-doc.tex
@@ -106,7 +106,7 @@
\url{https://github.com/samcarter/TikZbricks}\\
\url{https://www.ctan.org/pkg/tikzbricks}
}{samcarter}}
-\date{Version v0.3 \textendash{} 2021/08/13}
+\date{Version v0.4 \textendash{} 2022/07/21}
\begin{document}
\maketitle
@@ -115,8 +115,8 @@
\section{Introduction}
\label{intro}
-The idea for the \tikzbrick{}s package was born at the \href{https://tug.org/tug2021/}{TUG'21 conference}, at which one of the interviewees had a very cool collection of brick models in the background. % todo: link to video once this is available
-
+The idea for the \tikzbrick{}s package was born at the \href{https://tug.org/tug2021/}{TUG'21 conference}, at which one of the interviewees, John Hammersley, had a very cool collection of brick models in the background (\href{https://www.youtube.com/watch?v=-9_Iy5Fqr4E}{link to video}).
+
The package allows to draw bricks with \TikZ. The user can modify their colour, shape and change the viewpoint. Internally the \href{https://ctan.org/pkg/tikz-3dplot}{tikz-3dplot} package is used for the 3D rendering.
The package is included in both \texlive and \miktex and available from \CTAN (\url{https://ctan.org/pkg/tikzbricks}).
@@ -180,9 +180,9 @@ In addition to this basic block, the user can customise the block via the follow
\brick[studradius=0.2]{2}{1}
\end{tikzpicture}
\end{tcblisting}
-\begin{tcblisting}{title={Stud height (5)}}
+\begin{tcblisting}{title={Stud height (0.3)}}
\begin{tikzpicture}
- \brick[studheight=8]{2}{1}
+ \brick[studheight=0.6]{2}{1}
\end{tikzpicture}
\end{tcblisting}
\begin{tcblisting}{title={Stud text ()}}
@@ -191,13 +191,39 @@ In addition to this basic block, the user can customise the block via the follow
\end{tikzpicture}
\end{tcblisting}
+All the above options are also available as package options to change the value for the whole document. The default colour can for example be specified like this:
+\begin{tcolorbox}[title={Package options ()}]
+\begin{lstlisting}[morekeywords={tikzbricks,standalone,document}]
+\documentclass{standalone}
+
+\usepackage[color=blue]{tikzbricks}
+
+\begin{document}
+
+\begin{tikzpicture}
+\brick{3}{2}
+\end{tikzpicture}
+
+\end{document}
+\end{lstlisting}
+
+\tcblower
+\makeatletter
+\def\brick@default@color{blue}
+\makeatother
+\begin{tikzpicture}
+\brick{3}{2}
+\end{tikzpicture}
+\end{tcolorbox}
+
To change the viewpoint, one can make use of the fact, that the \texttt{tikz-3dplot} package is used internally. By default, the \tikzbrick{}s package uses \lstinline|\tdplotsetmaincoords{70}{160}|, but this can be adjusted as desired:
-\begin{tcblisting}{title={Viewport}}
+\begin{tcblisting}{title={Viewpoint}}
\tdplotsetmaincoords{70}{110}
\begin{tikzpicture}
\brick{4}{2}
\end{tikzpicture}
\end{tcblisting}
+Caveat: don't move away too far from the default viewpoint, otherwise the correct rendering of the brick is not guaranteed.
In addition to these \tikzbrick specific options, one can also use all normal Ti\emph{k}Z options:
\begin{tcblisting}{title={Ti\emph{k}Z options}}
@@ -226,6 +252,35 @@ Inside the \lstinline|wall| environment one can use \lstinline|\newrow| as a sho
\end{wall}
\end{tcblisting}
+\clearpage
+\section{img2bricks (by @Scott Pakin)}
+
+To make creating large structures easier, \href{https://github.com/spakin}{Scott Pakin} contributed the \lstinline|img2bricks| python script, which converts image into \tikzbrick{}s. The script can be downloaded from \url{https://github.com/samcarter/TikZbricks/blob/main/img2bricks}.
+
+The script can be executed with python:
+\begin{tcolorbox}[lower separated=false]
+\begin{lstlisting}
+python3 img2bricks image.png
+\end{lstlisting}
+\end{tcolorbox}
+
+Additional options are
+\begin{tcolorbox}[lower separated=false,,righthand width=0cm,right=0cm]
+\begin{lstlisting}[columns=flexible]
+-h, --help show an help message
+--output LATEX-FILE, -o LATEX-FILE name of output file
+--depth DEPTH depth of each brick
+--widths NUM[,NUM] comma-separated list of allowable brick widths
+\end{lstlisting}
+\end{tcolorbox}
+
+When preparing an image to convert into \tikzbrick{}s:
+\begin{itemize}
+\item consider using an image with transparent background so some of the edges of the bricks will be visible instead of just a solid wall
+\item image formats like .png are best suitable to avoid artefacts from image compression
+\item consider using small images with not too many pixels. Otherwise the resulting \tikzbrick wall gets very large and might not be compilable (Lua\TeX{} is a bit more lenient, but can't do wonders, either)
+\end{itemize}
+
\section{Example}
One example inspired by the documentation of the \href{https://www.ctan.org/pkg/pxpic}{pxpic package}:
diff --git a/graphics/pgf/contrib/tikzbricks/tikzbricks.sty b/graphics/pgf/contrib/tikzbricks/tikzbricks.sty
index 5cc38d67a0..bc8889a971 100644
--- a/graphics/pgf/contrib/tikzbricks/tikzbricks.sty
+++ b/graphics/pgf/contrib/tikzbricks/tikzbricks.sty
@@ -12,14 +12,32 @@
% See http://www.latex-project.org/lppl.txt
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\ProvidesPackage{tikzbricks}[2021/08/13 version v0.3 Drawing bricks with TikZ]
+\ProvidesPackage{tikzbricks}[2022/07/21 v0.4 Drawing bricks with TikZ]
\RequirePackage{tikz}
\RequirePackage{tikz-3dplot}
+\RequirePackage{xkeyval}
% setting a default viewpoint
\tdplotsetmaincoords{70}{160}
+% setting default values
+\DeclareOptionX{color}[red]{\def\brick@default@color{#1}}
+\DeclareOptionX{frontcolor}[\brick@color!60]{\def\brick@default@frontcolor{#1}}
+\DeclareOptionX{topcolor}[\brick@color!40]{\def\brick@default@topcolor{#1}}
+\DeclareOptionX{sidecolor}[\brick@color]{\def\brick@default@sidecolor{#1}}
+\DeclareOptionX{studcolor}[\brick@color]{\def\brick@default@studcolor{#1}}
+\DeclareOptionX{brickheight}[1.3]{\def\brick@default@height{#1}}
+\DeclareOptionX{bricklength}[1.0]{\def\brick@default@length{#1}}
+\DeclareOptionX{brickwidth}[1.0]{\def\brick@default@width{#1}}
+\DeclareOptionX{studradius}[0.35]{\def\brick@default@radius{#1}}
+\DeclareOptionX{studheight}[0.3]{\def\brick@default@studheight{#1}}
+\DeclareOptionX{studtext}[]{\def\brick@default@text{#1}}
+
+\ExecuteOptionsX{color,frontcolor,topcolor,sidecolor,studcolor,brickheight,bricklength,brickwidth,studradius,studheight,studtext}
+
+\ProcessOptionsX
+
% counter to dermine the position of a brick in a wall
\newcounter{brickx}
\newcounter{bricky}
@@ -80,27 +98,27 @@
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
color/.code = \def\brick@color{#1},
- color = red,
+ color = \brick@default@color,
frontcolor/.code = \def\brick@frontcolor{#1},
- frontcolor = \brick@color!60,
+ frontcolor = \brick@default@frontcolor,
topcolor/.code = \def\brick@topcolor{#1},
- topcolor = \brick@color!40,
+ topcolor = \brick@default@topcolor,
sidecolor/.code = \def\brick@sidecolor{#1},
- sidecolor = \brick@color,
+ sidecolor = \brick@default@sidecolor,
studcolor/.code = \def\brick@studcolor{#1},
- studcolor = \brick@color,
+ studcolor = \brick@default@studcolor,
brickheight/.code = \def\brick@height{#1},
- brickheight = 1.3,
+ brickheight = \brick@default@height,
bricklength/.code = \def\brick@length{#1},
- bricklength = 1.0,
+ bricklength = \brick@default@length,
brickwidth/.code = \def\brick@width{#1},
- brickwidth = 1.0,
+ brickwidth = \brick@default@width,
studradius/.code = \def\brick@radius{#1},
- studradius = 0.35,
+ studradius = \brick@default@radius,
studheight/.code = \def\brick@studheight{#1},
- studheight = 5,
+ studheight = \brick@default@studheight,
studtext/.code = \def\brick@text{#1},
- studtext = {},
+ studtext = \brick@default@text,
}
\newcommand{\brick@draw}[2]{%
@@ -121,19 +139,63 @@
\begin{scope}[tdplot_main_coords]
% Drawing faces
+ \pgfmathparse{sign(sin(\tdplotmainphi))}
+ \let\brick@sin\pgfmathresult
+ \pgfmathparse{sign(cos(\tdplotmainphi))}
+ \let\brick@cos\pgfmathresult
- % Front
- \fill[\brick@frontcolor,thick]
- (
- \brick@length*\value{brickx},
- {\brick@width*(#2+\value{bricky})},
- \brick@height*\value{brickz}
- )
- -- ++(\brick@length*#1,0,0)
- -- ++(0,0,\brick@height)
- -- ++(-\brick@length*#1,0,0)
- -- cycle;
-
+ \ifnum\brick@sin<0
+ % Right
+ \fill[\brick@sidecolor,thick]
+ (
+ \brick@length*\value{brickx},
+ \brick@width*\value{bricky},
+ \brick@height*\value{brickz}
+ )
+ -- ++(0,0,\brick@height)
+ -- ++(0,\brick@width*#2,0)
+ -- ++(0,0,-\brick@height)
+ -- cycle;
+ \else
+ % Left
+ \fill[\brick@sidecolor,thick]
+ (
+ {\brick@length*(#1+\value{brickx})},
+ \brick@width*\value{bricky},
+ \brick@height*\value{brickz}
+ )
+ -- ++(0,0,\brick@height)
+ -- ++(0,\brick@width*#2,0)
+ -- ++(0,0,-\brick@height)
+ -- cycle;
+ \fi
+
+ \ifnum\brick@cos<0
+ % Front
+ \fill[\brick@frontcolor,thick]
+ (
+ \brick@length*\value{brickx},
+ {\brick@width*(#2+\value{bricky})},
+ \brick@height*\value{brickz}
+ )
+ -- ++(\brick@length*#1,0,0)
+ -- ++(0,0,\brick@height)
+ -- ++(-\brick@length*#1,0,0)
+ -- cycle;
+ \else
+ % Back
+ \fill[\brick@frontcolor,thick]
+ (
+ \brick@length*\value{brickx},
+ \brick@width*\value{bricky},
+ \brick@height*\value{brickz}
+ )
+ -- ++(\brick@length*#1,0,0)
+ -- ++(0,0,\brick@height)
+ -- ++(-\brick@length*#1,0,0)
+ -- cycle;
+ \fi
+
% Top
\fill[\brick@topcolor,thick]
(
@@ -145,18 +207,8 @@
-- ++(\brick@length*#1,0,0)
-- +(0,-\brick@width*#2,0)
-- cycle;
-
- % Left
- \fill[\brick@sidecolor,thick]
- (
- {\brick@length*(#1+\value{brickx})},
- \brick@width*\value{bricky},
- \brick@height*\value{brickz}
- )
- -- ++(0,0,\brick@height)
- -- ++(0,\brick@width*#2,0)
- -- ++(0,0,-\brick@height)
- -- cycle;
+
+
% Drawing studs
\foreach \x in {1,...,#1}{
@@ -179,9 +231,9 @@
{\brick@height*(1+\value{brickz})}
)
++(canvas cs:x=-\brick@radius/0.35*10)
- -- ++(canvas cs:y=\brick@studheight)
+ -- ++(canvas cs:y=\brick@studheight*17.8)
-- ++(canvas cs:x=\brick@radius/0.35*20)
- -- ++(canvas cs:y=-\brick@studheight);
+ -- ++(canvas cs:y=-\brick@studheight*17.8);
% Top circle with text
\fill[\brick@topcolor]
@@ -190,7 +242,7 @@
{\brick@width*(\y-0.5+\value{bricky})},
{\brick@height*(1+\value{brickz})}
)
- ++(canvas cs:y=\brick@studheight)
+ ++(canvas cs:y=\brick@studheight*17.8)
circle [radius=\brick@radius]
node[\brick@color,scale=\scalingfactor*0.5, font=\sffamily] {\brick@text};