2

I am having a problem to apply a single nonlinear transformation to a path decorated with custom pics. A minimal example follows:

\documentclass[margin=5pt]{standalone}
\usepackage{tikz}
    \usetikzlibrary{decorations.markings}
    \usetikzlibrary{shapes}
    \usepgflibrary{curvilinear}
    \usepgfmodule{nonlineartransformations}

\begin{document}

\tikzset{
    cell/.pic={
        % Shading for the endothelial cells
        \pgfdeclareradialshading{centred}{\pgfqpoint{0bp}{0bp}}{%
            color(0bp)=(white);
            color(10bp)=(red!10!white);
            color(20bp)=(red!20!white);
            color(30bp)=(red!30!white);
            color(100bp)=(red)
        }

        \node[%
            draw,
            rounded rectangle,
            inner xsep=0.24cm,
            inner ysep=0.075cm,
            shade,
            shading=centred,
            ultra thin
        ]   at (0,0) {};

    }
}

\begin{tikzpicture}

    \def\wallSideStartX{0}
    \def\wallSideLength{15cm}

    \coordinate (origin) at (\wallSideStartX,0);

    \def\thickness{1.50cm}

    % Start nonlinear transformation
    \pgfsetcurvilinearbeziercurve
    {\pgfpointxy{0}{0}}{\pgfpointxy{10}{0}}
    {\pgfpointxy{20}{5}}{\pgfpointxy{20}{15}}
    \pgftransformnonlinear{\pgfgetlastxy\x\y%
    \pgfpointcurvilinearbezierorthogonal{\x}{\y}}%

    \draw[%
        fill=red
    ]   (origin)
        rectangle
        ++(\wallSideLength,\thickness);

    \path[%
        postaction=decorate,
        decoration={%
            markings,
            mark=between positions 0 and 1 step 5mm with{%
                \pic[%
                    %scale=0.7,
                    sloped,
                    transform shape
                ]   {cell};
            }
        }
    ]   (\wallSideStartX,0.5*\thickness)
        --
        ++(\wallSideLength,0);

\end{tikzpicture}

\end{document}

This code compiles to the following image: enter image description here

The same transformation is affecting somehow differently the decorations and the actual path underlining it. Ideally, I want that the decoration to follow the rectangle too.

I am not very experienced with nonlinear transformations in TikZ, so I suppose it could be some interaction of it with pics and decorated paths that I am not aware of and, so far, I could not find anything that could solve it. Could someone help me with a solution for it? Thanks a lot!

1 Answers1

3

I propose the following solution to your problem: I have positioned the image of the endothelial cell along a path. Play with the positions if the chain is not placed correctly.

\documentclass[margin=5pt]{standalone}
\usepackage{tikz}
    \usetikzlibrary{shapes}
    \usepgflibrary{curvilinear}
    \usepgfmodule{nonlineartransformations}

\begin{document}

\tikzset{
    cell/.pic={
        % Shading for the endothelial cells
        \pgfdeclareradialshading{centred}{\pgfqpoint{0bp}{0bp}}{%
            color(0bp)=(white);
            color(10bp)=(red!10!white);
            color(20bp)=(red!20!white);
            color(30bp)=(red!30!white);
            color(100bp)=(red)
        }

        \node[%
            draw,
            rounded rectangle,
            inner xsep=0.24cm,
            inner ysep=0.075cm,
            shade,
            shading=centred,
            ultra thin
        ]   at (0,0) {};

    }
}

\begin{tikzpicture}

    \def\wallSideStartX{0}
    \def\wallSideLength{15}

    \coordinate (origin) at (\wallSideStartX,0);

    \def\thickness{1.5}

    % Start nonlinear transformation
    \pgfsetcurvilinearbeziercurve
    {\pgfpointxy{0}{0}}{\pgfpointxy{10}{0}}
    {\pgfpointxy{20}{5}}{\pgfpointxy{20}{15}}
    \pgftransformnonlinear{\pgfgetlastxy\x\y%
    \pgfpointcurvilinearbezierorthogonal{\x}{\y}}%

    \draw[%
        fill=red
    ]   (origin)
        rectangle
        ++(\wallSideLength,\thickness);


    % added: chain of endothelial cells
    % space at the beginning: .033
    \foreach \i in {.02,.053,...,.683} {
        \path (\wallSideStartX,.5*\thickness)
            -- pic[pos=\i] {cell}
            ++(\wallSideLength,0);
    }
    % space at the end: .03
    \foreach \i in {.71,.74,...,1} {
        \path (\wallSideStartX,.5*\thickness)
            -- pic[pos=\i] {cell}
            ++(\wallSideLength,0);
    }
\end{tikzpicture}

\end{document}

output

Edit: I have tried to slope the cells along the way. Does this fit your needs or is the shape of the endothelial cells not correct but (very) important for you? As before, play with the individual parameters.

\documentclass[margin=5pt,tikz]{standalone}

\usepgflibrary{curvilinear} \usepgfmodule{nonlineartransformations}

\begin{document} \begin{tikzpicture}[ cellRectangle/.pic={ % The option 'rounded corners' does not work, because the geometric figure is too small! \draw[% outer color=red!30!white, inner color=white, ultra thin] (0,0) rectangle (.5,.15); }
] \newcommand\wallSideStartX{0} \newcommand\wallSideLength{15} \newcommand\thickness{1.5}

    \coordinate (origin) at (\wallSideStartX,0);

    % Start nonlinear transformation
    \pgfsetcurvilinearbeziercurve
    {\pgfpointxy{0}{0}}{\pgfpointxy{10}{0}}
    {\pgfpointxy{20}{5}}{\pgfpointxy{20}{15}}
    \pgftransformnonlinear{\pgfgetlastxy\x\y%
    \pgfpointcurvilinearbezierorthogonal{\x}{\y}}%

    \draw[%
        left color=red!70,
        right color=red!80,
    ]   (origin)
        rectangle
        ++(\wallSideLength,\thickness);


    % endothelial cells
    \foreach \i in {0.01,.046,...,.97} {
        \path (\wallSideStartX,.425*\thickness)
            -- pic[pos=\i] {cellRectangle}
            ++(\wallSideLength,0);
    }
\end{tikzpicture}
\begin{tikzpicture}[
    cellEllipse/.pic={
        \draw[%
            outer color=red!30!white,
            inner color=white,
            ultra thin] (0,0) 
                        ellipse
                        (.25cm and .14cm);
    }
]
    \newcommand\wallSideStartX{0}
    \newcommand\wallSideLength{15}
    \newcommand\thickness{1.5}

    \coordinate (origin) at (\wallSideStartX,0);

    % Start nonlinear transformation
    \pgfsetcurvilinearbeziercurve
    {\pgfpointxy{0}{0}}{\pgfpointxy{10}{0}}
    {\pgfpointxy{20}{5}}{\pgfpointxy{20}{15}}
    \pgftransformnonlinear{\pgfgetlastxy\x\y%
    \pgfpointcurvilinearbezierorthogonal{\x}{\y}}%

    \draw[%
        left color=red!70,
        right color=red!80,
    ]   (origin)
        rectangle
        ++(\wallSideLength,\thickness);


    % endothelial cells
    \foreach \i in {.025,.06,...,.99} {
        \path (\wallSideStartX,.5*\thickness)
            -- pic[pos=\i] {cellEllipse}
            ++(\wallSideLength,0);
    }
\end{tikzpicture}

\end{document}

rectangleCell output ellipseCell output

Unknown
  • 822
  • Nice, thank you! That worked fine. Just one doubt: do you know how to get the (indeed, endothelial) cells "sloped" along the path. I thought using \pic[pos=\i, sloped, transform shape] ... would work but it did not, apparently (not sure why). – iago.oliveira May 23 '22 at 23:51
  • @iago.oliveira I have made an edit based on your comment. Please check it. – Unknown May 24 '22 at 18:41
  • It works perfectly! Thank you very much. I will play with the parameters to adjust the cell shapes. – iago.oliveira May 25 '22 at 00:22