texlive[63952] Master/texmf-dist: tikzbricks (21jul22)

commits+karl at tug.org commits+karl at tug.org
Thu Jul 21 22:13:56 CEST 2022


Revision: 63952
          http://tug.org/svn/texlive?view=revision&revision=63952
Author:   karl
Date:     2022-07-21 22:13:56 +0200 (Thu, 21 Jul 2022)
Log Message:
-----------
tikzbricks (21jul22)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/tikzbricks/README.md
    trunk/Master/texmf-dist/doc/latex/tikzbricks/tikzbricks-doc.pdf
    trunk/Master/texmf-dist/doc/latex/tikzbricks/tikzbricks-doc.tex
    trunk/Master/texmf-dist/tex/latex/tikzbricks/tikzbricks.sty

Modified: trunk/Master/texmf-dist/doc/latex/tikzbricks/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tikzbricks/README.md	2022-07-20 23:49:15 UTC (rev 63951)
+++ trunk/Master/texmf-dist/doc/latex/tikzbricks/README.md	2022-07-21 20:13:56 UTC (rev 63952)
@@ -2,8 +2,10 @@
 
 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
 
 The project repository, including a bug tracker, can be found at https://github.com/samcarter/TikZbricks/issues

Modified: trunk/Master/texmf-dist/doc/latex/tikzbricks/tikzbricks-doc.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/tikzbricks/tikzbricks-doc.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/tikzbricks/tikzbricks-doc.tex	2022-07-20 23:49:15 UTC (rev 63951)
+++ trunk/Master/texmf-dist/doc/latex/tikzbricks/tikzbricks-doc.tex	2022-07-21 20:13:56 UTC (rev 63952)
@@ -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 @@
 	 \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 @@
 \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 at 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 @@
 \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}:

Modified: trunk/Master/texmf-dist/tex/latex/tikzbricks/tikzbricks.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/tikzbricks/tikzbricks.sty	2022-07-20 23:49:15 UTC (rev 63951)
+++ trunk/Master/texmf-dist/tex/latex/tikzbricks/tikzbricks.sty	2022-07-21 20:13:56 UTC (rev 63952)
@@ -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 at default@color{#1}}
+\DeclareOptionX{frontcolor}[\brick at color!60]{\def\brick at default@frontcolor{#1}}
+\DeclareOptionX{topcolor}[\brick at color!40]{\def\brick at default@topcolor{#1}}
+\DeclareOptionX{sidecolor}[\brick at color]{\def\brick at default@sidecolor{#1}}
+\DeclareOptionX{studcolor}[\brick at color]{\def\brick at default@studcolor{#1}}
+\DeclareOptionX{brickheight}[1.3]{\def\brick at default@height{#1}}
+\DeclareOptionX{bricklength}[1.0]{\def\brick at default@length{#1}}
+\DeclareOptionX{brickwidth}[1.0]{\def\brick at default@width{#1}}
+\DeclareOptionX{studradius}[0.35]{\def\brick at default@radius{#1}}
+\DeclareOptionX{studheight}[0.3]{\def\brick at default@studheight{#1}}
+\DeclareOptionX{studtext}[]{\def\brick at 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 at color{#1},
-  color               = red,
+  color               = \brick at default@color,
   frontcolor/.code    = \def\brick at frontcolor{#1},
-  frontcolor          = \brick at color!60,
+  frontcolor          = \brick at default@frontcolor,
   topcolor/.code      = \def\brick at topcolor{#1},
-  topcolor            = \brick at color!40,
+  topcolor            = \brick at default@topcolor,
   sidecolor/.code     = \def\brick at sidecolor{#1},
-  sidecolor           = \brick at color,  
+  sidecolor           = \brick at default@sidecolor,  
   studcolor/.code     = \def\brick at studcolor{#1},
-  studcolor           = \brick at color,    
+  studcolor           = \brick at default@studcolor,    
   brickheight/.code   = \def\brick at height{#1},
-  brickheight         = 1.3,
+  brickheight         = \brick at default@height,
   bricklength/.code   = \def\brick at length{#1},
-  bricklength         = 1.0,
+  bricklength         = \brick at default@length,
   brickwidth/.code    = \def\brick at width{#1},
-  brickwidth          = 1.0,    
+  brickwidth          = \brick at default@width,    
   studradius/.code    = \def\brick at radius{#1},
-  studradius          = 0.35,
+  studradius          = \brick at default@radius,
   studheight/.code    = \def\brick at studheight{#1},
-  studheight          = 5,
+  studheight          = \brick at default@studheight,
   studtext/.code      = \def\brick at text{#1},
-  studtext            = {},
+  studtext            = \brick at default@text,
 }
 
 \newcommand{\brick at draw}[2]{%
@@ -121,19 +139,63 @@
   \begin{scope}[tdplot_main_coords]
   
     % Drawing faces
+   \pgfmathparse{sign(sin(\tdplotmainphi))}
+   \let\brick at sin\pgfmathresult
+   \pgfmathparse{sign(cos(\tdplotmainphi))}
+   \let\brick at cos\pgfmathresult   
     
-    % Front
-    \fill[\brick at frontcolor,thick]
-      (
-        \brick at length*\value{brickx},
-        {\brick at width*(#2+\value{bricky})},
-        \brick at height*\value{brickz}
-      )
-      -- ++(\brick at length*#1,0,0) 
-      -- ++(0,0,\brick at height) 
-      -- ++(-\brick at length*#1,0,0) 
-      -- cycle;
-      
+    \ifnum\brick at sin<0
+      % Right
+      \fill[\brick at sidecolor,thick] 
+        (
+          \brick at length*\value{brickx},
+          \brick at width*\value{bricky},
+          \brick at height*\value{brickz}
+        ) 
+        -- ++(0,0,\brick at height) 
+        -- ++(0,\brick at width*#2,0) 
+        -- ++(0,0,-\brick at height) 
+        -- cycle;
+    \else
+      % Left
+      \fill[\brick at sidecolor,thick] 
+        (
+          {\brick at length*(#1+\value{brickx})},
+          \brick at width*\value{bricky},
+          \brick at height*\value{brickz}
+        ) 
+        -- ++(0,0,\brick at height) 
+        -- ++(0,\brick at width*#2,0) 
+        -- ++(0,0,-\brick at height) 
+        -- cycle;       
+    \fi
+    
+    \ifnum\brick at cos<0
+      % Front
+      \fill[\brick at frontcolor,thick]
+        (
+          \brick at length*\value{brickx},
+          {\brick at width*(#2+\value{bricky})},
+          \brick at height*\value{brickz}
+        )
+        -- ++(\brick at length*#1,0,0) 
+        -- ++(0,0,\brick at height) 
+        -- ++(-\brick at length*#1,0,0) 
+        -- cycle;
+    \else
+      % Back   
+      \fill[\brick at frontcolor,thick]
+        (
+          \brick at length*\value{brickx},
+          \brick at width*\value{bricky},
+          \brick at height*\value{brickz}
+        )
+        -- ++(\brick at length*#1,0,0) 
+        -- ++(0,0,\brick at height) 
+        -- ++(-\brick at length*#1,0,0) 
+        -- cycle;
+    \fi
+
     % Top 
     \fill[\brick at topcolor,thick] 
       (
@@ -145,19 +207,9 @@
       -- ++(\brick at length*#1,0,0) 
       -- +(0,-\brick at width*#2,0) 
       -- cycle;
-      
-    % Left
-    \fill[\brick at sidecolor,thick] 
-      (
-        {\brick at length*(#1+\value{brickx})},
-        \brick at width*\value{bricky},
-        \brick at height*\value{brickz}
-      ) 
-      -- ++(0,0,\brick at height) 
-      -- ++(0,\brick at width*#2,0) 
-      -- ++(0,0,-\brick at height) 
-      -- cycle; 
     
+
+    
     % Drawing studs
     \foreach \x in {1,...,#1}{
       \foreach \y in {1,...,#2}{
@@ -179,9 +231,9 @@
             {\brick at height*(1+\value{brickz})}
           ) 
           ++(canvas cs:x=-\brick at radius/0.35*10) 
-          -- ++(canvas cs:y=\brick at studheight) 
+          -- ++(canvas cs:y=\brick at studheight*17.8) 
           -- ++(canvas cs:x=\brick at radius/0.35*20) 
-          -- ++(canvas cs:y=-\brick at studheight);
+          -- ++(canvas cs:y=-\brick at studheight*17.8);
           
         % Top circle with text
         \fill[\brick at topcolor] 
@@ -190,7 +242,7 @@
             {\brick at width*(\y-0.5+\value{bricky})},
             {\brick at height*(1+\value{brickz})}
           ) 
-          ++(canvas cs:y=\brick at studheight) 
+          ++(canvas cs:y=\brick at studheight*17.8) 
           circle [radius=\brick at radius] 
           node[\brick at color,scale=\scalingfactor*0.5, font=\sffamily] {\brick at text};
 



More information about the tex-live-commits mailing list.