summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2022-07-21 20:13:56 +0000
committerKarl Berry <karl@freefriends.org>2022-07-21 20:13:56 +0000
commitdac3a8539c5d67eb472e6718ba16b1b46221460b (patch)
treed15db67e28e97015d3be9c5f7fc19c115ecb117a
parent0848974e73fc0712f8e3fe0f76fd3209bc1c8fab (diff)
tikzbricks (21jul22)
git-svn-id: svn://tug.org/texlive/trunk@63952 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/latex/tikzbricks/README.md4
-rw-r--r--Master/texmf-dist/doc/latex/tikzbricks/tikzbricks-doc.pdfbin259649 -> 271210 bytes
-rw-r--r--Master/texmf-dist/doc/latex/tikzbricks/tikzbricks-doc.tex67
-rw-r--r--Master/texmf-dist/tex/latex/tikzbricks/tikzbricks.sty130
4 files changed, 155 insertions, 46 deletions
diff --git a/Master/texmf-dist/doc/latex/tikzbricks/README.md b/Master/texmf-dist/doc/latex/tikzbricks/README.md
index 93029705e22..8cd336a7c3c 100644
--- a/Master/texmf-dist/doc/latex/tikzbricks/README.md
+++ b/Master/texmf-dist/doc/latex/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/Master/texmf-dist/doc/latex/tikzbricks/tikzbricks-doc.pdf b/Master/texmf-dist/doc/latex/tikzbricks/tikzbricks-doc.pdf
index 99f44e65cab..0b39ca2b618 100644
--- a/Master/texmf-dist/doc/latex/tikzbricks/tikzbricks-doc.pdf
+++ b/Master/texmf-dist/doc/latex/tikzbricks/tikzbricks-doc.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/tikzbricks/tikzbricks-doc.tex b/Master/texmf-dist/doc/latex/tikzbricks/tikzbricks-doc.tex
index 401ec1a20df..febcba5c366 100644
--- a/Master/texmf-dist/doc/latex/tikzbricks/tikzbricks-doc.tex
+++ b/Master/texmf-dist/doc/latex/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/Master/texmf-dist/tex/latex/tikzbricks/tikzbricks.sty b/Master/texmf-dist/tex/latex/tikzbricks/tikzbricks.sty
index 5cc38d67a0a..bc8889a9717 100644
--- a/Master/texmf-dist/tex/latex/tikzbricks/tikzbricks.sty
+++ b/Master/texmf-dist/tex/latex/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};