2

How to draw for instance a beam (or even fancier forms) from a given center line? Here is what i mean but with a rather not so good solution. I would like to add pattern, etc.

\documentclass[12pt,tikz,border=5pt]{standalone}
\usetikzlibrary{calc}


\begin{document}

\begin{tikzpicture}
% grid to see the coordinates

% Point A with circle and label
\coordinate [label={[label distance=3mm]below:A}] (A) at (1,3);

% Point B with circle and label
\coordinate [label={[label distance=3mm]right:B}](B) at (6,6);

% Point C with circle and label
\coordinate [label={[label distance=3mm]below:C}](C) at (7,4);

% Point D with circle and label
\coordinate [label={[label distance=3mm]right:D}](D) at (9,4);
\draw (D) circle [radius=3pt];

\draw[line width=20pt,line cap=round] (A) -- (B) -- (C) -- (D); 
\draw[line width=14pt,white,line cap=round] (A) -- (B) -- (C) -- (D);    
\draw (A) -- (B) -- (C) -- (D);

% grid to see the coordinates
\draw[help lines, step=1] (0,0) grid (10,8);

\draw (A) circle [radius=3pt];
\draw (B) circle [radius=3pt];
\draw (C) circle [radius=3pt];
\draw (D) circle [radius=3pt];

\end{tikzpicture}
\end{document}

enter image description here

  • Do you mean TikZ decorations? Have a look at chapter 24 of the current TikZ/PGF documentation. – Turion Jan 7 '15 at 22:25
  • i know about the decoration library and i will look at this library. but from the idea: i want a knew path around the given skeleton line and than make fancy things (decorations) to this new path. – Nik Jan 9 '15 at 14:34
1

You can adapt my previous answer like this:

\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{calc}
\usetikzlibrary{patterns}
\tikzset{
  rect/.style= { to path={ let \n1={sqrt(2)*#1},
    \p1=($(\tikztostart)!\n1!-135:(\tikztotarget)$), \p2=($(\tikztostart)!\n1!135:(\tikztotarget)$),
    \p3=($(\tikztotarget)!\n1!-135:(\tikztostart)$), \p4=($(\tikztotarget)!\n1!135:(\tikztostart)$)
    in (\p1) -- (\p2) -- (\p3) -- (\p4) --cycle (\tikztotarget)}
  },
  round/.style={rounded corners=#1,rect/.default=#1}
}
\begin{document}
  \begin{tikzpicture}
    \draw[help lines] (0,0) grid (7,5);

    \def\mypath{(1,2) foreach \a in {30,-45,0,90} {to[rect] ++(\a:2)}}
    \fill[round=4mm,black] \mypath;
    \shade[round=3mm,left color=red, right color=blue] \mypath;
    \pattern[round=3mm,pattern color=white,pattern=bricks] \mypath;

  \end{tikzpicture}
\end{document}

enter image description here

  • that ist what I had in mind. i will later explore your code. but can i ask you to make a picture with everywhere rounded corners? to get the body of a snake :-) ? – Nik Jan 9 '15 at 14:30
  • @Nik probably you want another patern too, but I'll let you do this by yourself. Putting a circle is not so hard ;) – Kpym Jan 9 '15 at 14:53
  • Kpym ok ok ok ok – Nik Jan 9 '15 at 16:21
  • i want to write: @Kpym but i don't get this. not at the beginning of the comment. – Nik Jan 9 '15 at 16:24
  • You don't need @ for the author of the answer/question. It is automaticaly informed. You can add only one @ to informe somebody else too. Here for more info : meta.stackexchange.com/a/43020 – Kpym Jan 9 '15 at 16:38
1

Use pgf-blur. The documentation says that the shadow is always black. But it is not hard to find out that black and replace it by our \blurcolor

\documentclass[tikz]{standalone}
\usetikzlibrary{shadows.blur}
\makeatletter
\tikzset{
    /tikz/render blur shadow/.code={
        \pgfbs@savebb
        \pgfsyssoftpath@getcurrentpath{\pgfbs@input@path}%
        \pgfbs@compute@shadow@bbox
        \pgfbs@process@rounding{\pgfbs@input@path}{\pgfbs@fadepath}%
        \pgfbs@apply@canvas@transform
        \colorlet{pstb@shadow@color}{white!\pgfbs@opacity!black}%
        \pgfdeclarefading{shadowfading}{\pgfbs@paint@fading}%
        \pgfsetfillcolor{\blurcolor}%
        \pgfsetfading{shadowfading}%
            {\pgftransformshift{\pgfpoint{\pgfbs@midx}{\pgfbs@midy}}}%
        \pgfbs@usebbox{fill}%
        \pgfbs@restorebb
    }
}
\begin{document}
    \begin{tikzpicture}
        \fill[black](0,2)rectangle(10,7);
        \def\blurcolor{yellow}
        \path[blur shadow,shadow xshift=0,shadow yshift=0,
              shadow blur radius=20pt,shadow opacity=100,shadow blur steps=100]
            (1,3)--(6,6)--cycle(6,6)--(7,4)--cycle(7,4)--(9,4)--cycle;
    \end{tikzpicture}
\end{document}
  • @Nik when you like one answer, a good practice is to upvote it. – Kpym Jan 9 '15 at 14:54
  • sorry. done. ok i get this @ here but not at the beginning of the comment? – Nik Jan 9 '15 at 16:22

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.