4

For bw printing, I'd like to rotate the filling pattern. How to do this ?

enter image description here

\documentclass[margin=2pt]{standalone}
\usepackage{tikz,siunitx}
\usetikzlibrary{%
    calc,
    intersections,
    patterns}

\begin{document}
\hfill\begin{tikzpicture}[%
    every node/.style={font=\small}]

\def\X{3.5}

\coordinate (A) at (90:\X) ;
\coordinate (B) at (210:\X) ;
\coordinate (C) at (-30:\X) ;

\coordinate (I) at ($(A)!.5!(B)$) ;
\coordinate (J) at ($(A)!.5!(C)$) ;
\coordinate (K) at ($(C)!.5!(B)$) ;
\coordinate (E) at ($(B)!.5!(K)$) ;
\coordinate (F) at ($(C)!.5!(K)$) ;

\coordinate (N) at ($(E)!(F)!(J)$) ;
\coordinate (M) at ($(E)!(I)!(J)$) ;

\coordinate (N') at ($(N)!2!(J)$) ;
\coordinate (F') at ($(F)!2!(J)$) ;
\coordinate (M') at ($(M)!2!(I)$) ;
\coordinate (E') at ($(E)!2!(I)$) ;

\begin{scope}
\clip (0,0) rectangle (0,0) ;

\draw[name path=P1] (N')--($(N')!3!(F')$) ;
\draw[name path=P2] (M')--($(M')!3!(E')$) ;

\path[name intersections={%
    of= P1 and P2,  % nom des paths
    by=D,           % nom des points
    sort by=P1,     % suivant le path
    total=\t}]      % nb de points
\pgfextra{\xdef\InterNb{\t} } ;

\end{scope}

\fill[pattern=checkerboard light gray] (M)--(I)--(A)--(J)--cycle ;

\path[pattern=horizontal lines light blue] (E)--(M)--(I)--(B)--cycle;
\path[pattern=horizontal lines light blue] (E')--(M')--(I)--(A)--cycle;

\path[pattern=horizontal lines light gray] (F)--(N)--(J)--(C)--cycle;
\path[pattern=horizontal lines light gray] (F')--(N')--(J)--(A)--cycle;

%\draw pic[%
%   "\SI{71}{\degree}",
%   draw,
%   fill=blue!15,
%   angle eccentricity=1.4,
%   angle radius=.7cm
%   ] {angle=B--I--M} ;

%\draw pic[%
%   "\SI{131}{\degree}",
%   draw,
%   fill=blue!15,
%   angle eccentricity=1.5,
%   angle radius=.6cm
%   ] {angle=C--F--N} ;

%\draw pic[%
%   "\SI{101}{\degree}",
%   draw,
%   fill=blue!15,
%   angle eccentricity=1.7,
%   angle radius=.6cm
%   ] {angle=A--J--E} ;


\draw (A)--(B)--(C)--cycle ;
\draw (J)--(E) ;
\draw (I)--(M) ;
\draw (F)--(N) ;

\draw (F')--(E') ;
\draw[thick] (M)--(N')--(D)--(M')--cycle ;

\foreach \Coor/\Text/\Pos in 
    {A/$A$/90,
    B/$B$/-135,
    C/$C$/-45,
    E/$E$/-90,
    F/$F$/-90,
    I/$I$/180,
    J/$J$/0,
    M/$M$/-80,
    N/$N$/100%
    } {%
%   \path (\Coor) pic {Cross={2 and black}} ;
    %\node[small dot] at (\Coor) {} ;
    \node[shift=(\Pos:8pt),anchor=center] at (\Coor) {\Text} ;
    }

\end{tikzpicture}\hfill\strut
\end{document}
4

As bmv already answered, it's not possible to rotate a pattern, but it's not too difficult to define new rotated patterns.

Information about it can be found in section 104 Patterns and already defined styles can be found in file pgflibrarypatterns.code.tex.

Based on checkerboard light gray and horizontal lines light gray I've defined rotated checkerboard light gray and vertical lines light gray. The code can be found in following lines:

\documentclass[margin=2pt]{standalone}
\usepackage{tikz,siunitx}
\usetikzlibrary{%
    calc,
    intersections,
    patterns}

\pgfdeclarepatterninherentlycolored{rotated checkerboard light gray}
{\pgfpointorigin}{\pgfqpoint{4mm}{4mm}}{\pgfqpoint{4mm}{4mm}}%
{
  \pgfsetfillcolor{black!10}
  \pgfpathrectangle{\pgfpointorigin}{\pgfqpoint{4.1mm}{4.1mm}}% make
                                % slightly larger to ensure that tiles
                                % are really solid
  \pgfusepath{fill}
  \pgfsetfillcolor{black!20}
  \pgfpathmoveto{\pgfqpoint{0mm}{2mm}}
  \pgfpathlineto{\pgfqpoint{2mm}{4mm}}
  \pgfpathlineto{\pgfqpoint{4mm}{2mm}}
  \pgfpathlineto{\pgfqpoint{2mm}{0mm}}
  \pgfpathlineto{\pgfqpoint{0mm}{2mm}}
  \pgfusepath{fill}
}

\pgfdeclarepatterninherentlycolored{vertical lines light gray}
{\pgfpointorigin}{\pgfpoint{4pt}{100pt}}
{\pgfpoint{4pt}{100pt}}
{
  \pgfsetfillcolor{black!10}
  \pgfpathrectangle{\pgfpointorigin}{\pgfpoint{2.5pt}{100pt}}
  \pgfusepath{fill}
  \pgfsetfillcolor{black!15}
  \pgfpathrectangle{\pgfpoint{2pt}{0pt}}{\pgfpoint{2.5pt}{100pt}}
  \pgfusepath{fill}
}

\begin{document}
\hfill\begin{tikzpicture}[%
    every node/.style={font=\small}]

\def\X{3.5}

\coordinate (A) at (90:\X) ;
\coordinate (B) at (210:\X) ;
\coordinate (C) at (-30:\X) ;

\coordinate (I) at ($(A)!.5!(B)$) ;
\coordinate (J) at ($(A)!.5!(C)$) ;
\coordinate (K) at ($(C)!.5!(B)$) ;
\coordinate (E) at ($(B)!.5!(K)$) ;
\coordinate (F) at ($(C)!.5!(K)$) ;

\coordinate (N) at ($(E)!(F)!(J)$) ;
\coordinate (M) at ($(E)!(I)!(J)$) ;

\coordinate (N') at ($(N)!2!(J)$) ;
\coordinate (F') at ($(F)!2!(J)$) ;
\coordinate (M') at ($(M)!2!(I)$) ;
\coordinate (E') at ($(E)!2!(I)$) ;

\begin{scope}
\clip (0,0) rectangle (0,0) ;

\draw[name path=P1] (N')--($(N')!3!(F')$) ;
\draw[name path=P2] (M')--($(M')!3!(E')$) ;

\path[name intersections={%
    of= P1 and P2,  % nom des paths
    by=D,           % nom des points
    sort by=P1,     % suivant le path
    total=\t}]      % nb de points
\pgfextra{\xdef\InterNb{\t} } ;

\end{scope}

\fill[pattern=rotated checkerboard light gray] (M)--(I)--(A)--(J)--cycle ;

\path[pattern=horizontal lines light blue] (E)--(M)--(I)--(B)--cycle;
\path[pattern=horizontal lines light blue] (E')--(M')--(I)--(A)--cycle;

\path[pattern=vertical lines light gray] (F)--(N)--(J)--(C)--cycle;
\path[pattern=horizontal lines light gray] (F')--(N')--(J)--(A)--cycle;

%\draw pic[%
%   "\SI{71}{\degree}",
%   draw,
%   fill=blue!15,
%   angle eccentricity=1.4,
%   angle radius=.7cm
%   ] {angle=B--I--M} ;

%\draw pic[%
%   "\SI{131}{\degree}",
%   draw,
%   fill=blue!15,
%   angle eccentricity=1.5,
%   angle radius=.6cm
%   ] {angle=C--F--N} ;

%\draw pic[%
%   "\SI{101}{\degree}",
%   draw,
%   fill=blue!15,
%   angle eccentricity=1.7,
%   angle radius=.6cm
%   ] {angle=A--J--E} ;


\draw (A)--(B)--(C)--cycle ;
\draw (J)--(E) ;
\draw (I)--(M) ;
\draw (F)--(N) ;

\draw (F')--(E') ;
\draw[thick] (M)--(N')--(D)--(M')--cycle ;

\foreach \Coor/\Text/\Pos in 
    {A/$A$/90,
    B/$B$/-135,
    C/$C$/-45,
    E/$E$/-90,
    F/$F$/-90,
    I/$I$/180,
    J/$J$/0,
    M/$M$/-80,
    N/$N$/100%
    } {%
%   \path (\Coor) pic {Cross={2 and black}} ;
    %\node[small dot] at (\Coor) {} ;
    \node[shift=(\Pos:8pt),anchor=center] at (\Coor) {\Text} ;
    }

\end{tikzpicture}\hfill\strut
\end{document}

enter image description here

6

From TikZ & PGF Manual for Version 3.0.1a p. 171 (thanks to @Zarko)

Patterns are not overly flexible. In particular, it is not possible to change the size or orientation of a pattern without declaring a new pattern. For complicated case, it may be easier to use two nested \foreach statements to simulate a pattern, but patterns are rendered much more quickly than simulated ones.

  • but now is actual tikz v3.0.1a. in this is described on section 15.5.1 Graphic Parameters: Fill Pattern, page 171 ... – Zarko Feb 3 '18 at 10:40
  • Which is the file that contains the definitions of this patterns, and where to find it ? – Tarass Feb 3 '18 at 11:28
  • In my experience, it's a huge pain to even translate patterns. – Hood Chatham Feb 4 '18 at 19:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.