Skip to main content
deleted 147 characters in body
Source Link
user194703
user194703

(For some reason \pgfgetlastxy seems to work for all but the very first node of the tikzpicture. This is the reason for \path (0,0); here.)

Finally, let me mention that patterns are tricky (OK, we know that;-): if you convert the resulting pdf to another format, the patterns may get shifted around.

(For some reason \pgfgetlastxy seems to work for all but the very first node of the tikzpicture. This is the reason for \path (0,0); here.)

Finally, let me mention that patterns are tricky (OK, we know that;-): if you convert the resulting pdf to another format, the patterns may get shifted around.

Finally, let me mention that patterns are tricky (OK, we know that;-): if you convert the resulting pdf to another format, the patterns may get shifted around.

deleted 2270 characters in body
Source Link
user194703
user194703

One can also make the pattern transformation part of the definition of the nodes, but this requires some extra work.

\documentclass[tikz,border=5mm]{standalone} \usetikzlibrary{patterns.meta} \pgfdeclarepattern{ name=MovableLines, parameters={ \pgfkeysvalueof{/pgf/pattern keys/distance}, \pgfkeysvalueof{/pgf/pattern keys/angle}, \pgfkeysvalueof{/pgf/pattern keys/xshift}, \pgfkeysvalueof{/pgf/pattern keys/yshift}, \pgfkeysvalueof{/pgf/pattern keys/line width}, }, bottom left={% \pgfpoint {-.5*(\pgfkeysvalueof{/pgf/pattern keys/distance})}% {-.5*(\pgfkeysvalueof{/pgf/pattern keys/distance})}}, top right={% \pgfpoint {.5*(\pgfkeysvalueof{/pgf/pattern keys/distance})}% {.5*(\pgfkeysvalueof{/pgf/pattern keys/distance})}}, tile size={% \pgfpoint {\pgfkeysvalueof{/pgf/pattern keys/distance}}% {\pgfkeysvalueof{/pgf/pattern keys/distance}}}, tile transformation={% \pgftransformshift{% \pgfpoint {\pgfkeysvalueof{/pgf/pattern keys/xshift}}% {\pgfkeysvalueof{/pgf/pattern keys/yshift}}}% \pgftransformrotate{\pgfkeysvalueof{/pgf/pattern keys/angle}}}, defaults={ distance/.initial=3pt, angle/.initial=0, xshift/.initial=0pt, yshift/.initial=0pt, line width/.initial=\the\pgflinewidth, }, code={% \pgfsetlinewidth{\pgfkeysvalueof{/pgf/pattern keys/line width}}% \pgfpathmoveto{\pgfpoint{-.5*(\pgfkeysvalueof{/pgf/pattern keys/distance})}{0pt}}% \pgfpathlineto{\pgfpoint{.5*(\pgfkeysvalueof{/pgf/pattern keys/distance})}{0pt}}% \pgfusepath{stroke}% }, } \begin{document} \begin{tikzpicture}[here/.code={\pgfgetlastxy{\myx}{\myy}}] \path (0,0); \foreach \n in {0,...,5} { \node [rectangle,draw,minimum size=1cm,here, pattern={MovableLines[xshift={\myx},yshift={\myy},angle=-45,distance={sqrt(0.5)*3pt}, line width=0.4pt]}] at (1.1*\n cm, 0) {}; \node [rectangle,draw,minimum size=1cm,here, pattern={Dots[xshift={\myx},yshift={\myy}]}] at (1.1*\n cm, 1.1) {}; } \end{tikzpicture} \end{document} 

enter image description here

One can also make the pattern transformation part of the definition of the nodes.

\documentclass[tikz,border=5mm]{standalone} \usetikzlibrary{patterns.meta} \pgfdeclarepattern{ name=MovableLines, parameters={ \pgfkeysvalueof{/pgf/pattern keys/distance}, \pgfkeysvalueof{/pgf/pattern keys/angle}, \pgfkeysvalueof{/pgf/pattern keys/xshift}, \pgfkeysvalueof{/pgf/pattern keys/yshift}, \pgfkeysvalueof{/pgf/pattern keys/line width}, }, bottom left={% \pgfpoint {-.5*(\pgfkeysvalueof{/pgf/pattern keys/distance})}% {-.5*(\pgfkeysvalueof{/pgf/pattern keys/distance})}}, top right={% \pgfpoint {.5*(\pgfkeysvalueof{/pgf/pattern keys/distance})}% {.5*(\pgfkeysvalueof{/pgf/pattern keys/distance})}}, tile size={% \pgfpoint {\pgfkeysvalueof{/pgf/pattern keys/distance}}% {\pgfkeysvalueof{/pgf/pattern keys/distance}}}, tile transformation={% \pgftransformshift{% \pgfpoint {\pgfkeysvalueof{/pgf/pattern keys/xshift}}% {\pgfkeysvalueof{/pgf/pattern keys/yshift}}}% \pgftransformrotate{\pgfkeysvalueof{/pgf/pattern keys/angle}}}, defaults={ distance/.initial=3pt, angle/.initial=0, xshift/.initial=0pt, yshift/.initial=0pt, line width/.initial=\the\pgflinewidth, }, code={% \pgfsetlinewidth{\pgfkeysvalueof{/pgf/pattern keys/line width}}% \pgfpathmoveto{\pgfpoint{-.5*(\pgfkeysvalueof{/pgf/pattern keys/distance})}{0pt}}% \pgfpathlineto{\pgfpoint{.5*(\pgfkeysvalueof{/pgf/pattern keys/distance})}{0pt}}% \pgfusepath{stroke}% }, } \begin{document} \begin{tikzpicture}[here/.code={\pgfgetlastxy{\myx}{\myy}}] \path (0,0); \foreach \n in {0,...,5} { \node [rectangle,draw,minimum size=1cm,here, pattern={MovableLines[xshift={\myx},yshift={\myy},angle=-45,distance={sqrt(0.5)*3pt}, line width=0.4pt]}] at (1.1*\n cm, 0) {}; \node [rectangle,draw,minimum size=1cm,here, pattern={Dots[xshift={\myx},yshift={\myy}]}] at (1.1*\n cm, 1.1) {}; } \end{tikzpicture} \end{document} 

enter image description here

One can also make the pattern transformation part of the definition of the nodes, but this requires some extra work.

added 2444 characters in body
Source Link
user194703
user194703

One can definitelyalso make the pattern transformation part of the definition of the nodes. Please let me know if this is

\documentclass[tikz,border=5mm]{standalone} \usetikzlibrary{patterns.meta} \pgfdeclarepattern{ name=MovableLines, parameters={ \pgfkeysvalueof{/pgf/pattern keys/distance}, \pgfkeysvalueof{/pgf/pattern keys/angle}, \pgfkeysvalueof{/pgf/pattern keys/xshift}, \pgfkeysvalueof{/pgf/pattern keys/yshift}, \pgfkeysvalueof{/pgf/pattern keys/line width}, }, bottom left={% \pgfpoint {-.5*(\pgfkeysvalueof{/pgf/pattern keys/distance})}% {-.5*(\pgfkeysvalueof{/pgf/pattern keys/distance})}}, top right={% \pgfpoint {.5*(\pgfkeysvalueof{/pgf/pattern keys/distance})}% {.5*(\pgfkeysvalueof{/pgf/pattern keys/distance})}}, tile size={% \pgfpoint {\pgfkeysvalueof{/pgf/pattern keys/distance}}% {\pgfkeysvalueof{/pgf/pattern keys/distance}}}, tile transformation={% \pgftransformshift{% \pgfpoint {\pgfkeysvalueof{/pgf/pattern keys/xshift}}% {\pgfkeysvalueof{/pgf/pattern keys/yshift}}}% \pgftransformrotate{\pgfkeysvalueof{/pgf/pattern keys/angle}}}, defaults={ distance/.initial=3pt, angle/.initial=0, xshift/.initial=0pt, yshift/.initial=0pt, line width/.initial=\the\pgflinewidth, }, code={% \pgfsetlinewidth{\pgfkeysvalueof{/pgf/pattern keys/line width}}% \pgfpathmoveto{\pgfpoint{-.5*(\pgfkeysvalueof{/pgf/pattern keys/distance})}{0pt}}% \pgfpathlineto{\pgfpoint{.5*(\pgfkeysvalueof{/pgf/pattern keys/distance})}{0pt}}% \pgfusepath{stroke}% }, } \begin{document} \begin{tikzpicture}[here/.code={\pgfgetlastxy{\myx}{\myy}}] \path (0,0); \foreach \n in {0,...,5} { \node [rectangle,draw,minimum size=1cm,here, pattern={MovableLines[xshift={\myx},yshift={\myy},angle=-45,distance={sqrt(0.5)*3pt}, line width=0.4pt]}] at (1.1*\n cm, 0) {}; \node [rectangle,draw,minimum size=1cm,here, pattern={Dots[xshift={\myx},yshift={\myy}]}] at (1.1*\n cm, 1.1) {}; } \end{tikzpicture} \end{document} 

enter image description here

(For some reason \pgfgetlastxy seems to be spelled outwork for all but the very first node of the tikzpicture. This is the reason for \path (0,0); here.)

One can definitely make the pattern transformation part of the definition of the nodes. Please let me know if this is to be spelled out.

One can also make the pattern transformation part of the definition of the nodes.

\documentclass[tikz,border=5mm]{standalone} \usetikzlibrary{patterns.meta} \pgfdeclarepattern{ name=MovableLines, parameters={ \pgfkeysvalueof{/pgf/pattern keys/distance}, \pgfkeysvalueof{/pgf/pattern keys/angle}, \pgfkeysvalueof{/pgf/pattern keys/xshift}, \pgfkeysvalueof{/pgf/pattern keys/yshift}, \pgfkeysvalueof{/pgf/pattern keys/line width}, }, bottom left={% \pgfpoint {-.5*(\pgfkeysvalueof{/pgf/pattern keys/distance})}% {-.5*(\pgfkeysvalueof{/pgf/pattern keys/distance})}}, top right={% \pgfpoint {.5*(\pgfkeysvalueof{/pgf/pattern keys/distance})}% {.5*(\pgfkeysvalueof{/pgf/pattern keys/distance})}}, tile size={% \pgfpoint {\pgfkeysvalueof{/pgf/pattern keys/distance}}% {\pgfkeysvalueof{/pgf/pattern keys/distance}}}, tile transformation={% \pgftransformshift{% \pgfpoint {\pgfkeysvalueof{/pgf/pattern keys/xshift}}% {\pgfkeysvalueof{/pgf/pattern keys/yshift}}}% \pgftransformrotate{\pgfkeysvalueof{/pgf/pattern keys/angle}}}, defaults={ distance/.initial=3pt, angle/.initial=0, xshift/.initial=0pt, yshift/.initial=0pt, line width/.initial=\the\pgflinewidth, }, code={% \pgfsetlinewidth{\pgfkeysvalueof{/pgf/pattern keys/line width}}% \pgfpathmoveto{\pgfpoint{-.5*(\pgfkeysvalueof{/pgf/pattern keys/distance})}{0pt}}% \pgfpathlineto{\pgfpoint{.5*(\pgfkeysvalueof{/pgf/pattern keys/distance})}{0pt}}% \pgfusepath{stroke}% }, } \begin{document} \begin{tikzpicture}[here/.code={\pgfgetlastxy{\myx}{\myy}}] \path (0,0); \foreach \n in {0,...,5} { \node [rectangle,draw,minimum size=1cm,here, pattern={MovableLines[xshift={\myx},yshift={\myy},angle=-45,distance={sqrt(0.5)*3pt}, line width=0.4pt]}] at (1.1*\n cm, 0) {}; \node [rectangle,draw,minimum size=1cm,here, pattern={Dots[xshift={\myx},yshift={\myy}]}] at (1.1*\n cm, 1.1) {}; } \end{tikzpicture} \end{document} 

enter image description here

(For some reason \pgfgetlastxy seems to work for all but the very first node of the tikzpicture. This is the reason for \path (0,0); here.)

added 499 characters in body
Source Link
user194703
user194703
Loading
added 1675 characters in body
Source Link
user194703
user194703
Loading
Source Link
user194703
user194703
Loading