tikz - 弯曲的云形

tikz - 弯曲的云形

这是我的代码,它生成一个圆圈,圆圈内有文字,圆圈周围有三朵云,云上也有文字。如果可能的话,我希望云能绕圆圈呈弧形弯曲。有这个线程这里,但我不知道如何将代码应用到我的情况

\documentclass[tikz, preview=true, border=2mm]{standalone}

\renewcommand*\familydefault{\sfdefault}

\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{mindmap,trees,shadows}
\usetikzlibrary{positioning}
\usetikzlibrary{shapes}
\pgfplotsset{compat=1.7}

\begin{document}
    \makeatletter
    \def\tikz@compute@circle@radii@b{%
        \pgf@process{\pgfpointtransformed{\pgfpointanchor{\tikztostart}{center}}}%
        \pgf@xa=\pgf@x%
        \pgf@process{\pgfpointtransformed{\pgfpointanchor{\tikztostart}{west}}}%
        \advance\pgf@xa by-\pgf@x%
        \pgf@xa=.6\pgf@xa\relax%
        \pgfkeys{/pgf/decoration/start radius/.expanded=\the\pgf@xa}%
        \pgf@process{\pgfpointtransformed{\pgfpointanchor{\tikztotarget}{center}}}%
        \pgf@xa=\pgf@x%
        \pgf@process{\pgfpointtransformed{\pgfpointanchor{\tikztotarget}{west}}}%
        \advance\pgf@xa by-\pgf@x%
        \pgf@xa=.3\pgf@xa\relax%
        \pgfkeys{/pgf/decoration/end radius/.expanded=\the\pgf@xa}%
    }

    \def\tikz@compute@segmentamplitude@b{%
        \pgf@x=\pgfkeysvalueof{/pgf/decoration/start radius}\relax%
        \ifdim\pgf@x>\pgfkeysvalueof{/pgf/decoration/end radius}\relax%
        \pgf@x=\pgfkeysvalueof{/pgf/decoration/end radius}\relax%
        \fi%
        \pgf@x=.4\pgf@x\relax%
        \edef\pgfdecorationsegmentamplitude{\the\pgf@x}%
    }
    \tikzoption{thick bar concept color}{%
        \let\tikz@old@concept@color=\tikz@concept@color%
        \let\tikz@old@compute@circle@radii=\tikz@compute@circle@radii%
        \let\tikz@compute@circle@radii=\tikz@compute@circle@radii@b%
        \let\tikz@old@compute@segmentamplitude=\tikz@compute@segmentamplitude%
        \let\tikz@compute@segmentamplitude=\tikz@compute@segmentamplitude@b%
        \def\tikz@edge@to@parent@path{
            (\tikzparentnode)
            to[circle connection bar switch color=from (\tikz@old@concept@color) to (#1)]
            (\tikzchildnode)}
        \def\tikz@concept@color{#1}%
    }
    \tikzoption{thicker bar concept color}{%
        \let\tikz@old@concept@color=\tikz@concept@color%
        \let\tikz@old@compute@circle@radii=\tikz@compute@circle@radii%
        \let\tikz@compute@circle@radii=\tikz@compute@circle@radii@b%
        \let\tikz@old@compute@segmentamplitude=\tikz@compute@segmentamplitude%
        \let\tikz@compute@segmentamplitude=\tikz@old@compute@segmentamplitude%
        \def\tikz@edge@to@parent@path{
            (\tikzparentnode)
            to[circle connection bar switch color=from (\tikz@old@concept@color) to (#1)]
            (\tikzchildnode)}
        \def\tikz@concept@color{#1}%
    }
    \tikzoption{standard bar concept color}{%
        \let\tikz@old@concept@color=\tikz@concept@color%
        \let\tikz@compute@circle@radii=\tikz@old@compute@circle@radii%
        \let\tikz@compute@segmentamplitude=\tikz@old@compute@segmentamplitude%
        \def\tikz@edge@to@parent@path{
            (\tikzparentnode)
            to[circle connection bar switch color=from (\tikz@old@concept@color) to (#1)]
            (\tikzchildnode)}
        \def\tikz@concept@color{#1}%
    }

    \makeatother

    \begin{tikzpicture}

    \begin{scope}[mindmap,
    every node/.style={concept, circular drop shadow, minimum size=0pt,execute at begin node=\hskip0pt},
    root concept/.append style={
        concept color=black, line width=1.5ex},
    level 1 concept/.append style={},
    text=white,
    partner/.style={thick bar concept color=gray!70!black},
    colleague/.style={thicker bar concept color=gray!70!black},
    staff/.style={standard bar concept color=gray!70!black},
    grow cyclic,
    level 1/.append style={level distance=6.2cm,sibling angle=45},
    level 2/.append style={level distance=3cm,sibling angle=45},
    ]
    \node [root concept,font=\huge] {\color{white}Big text}
    child[partner, grow=30, level distance=45mm] {node[draw=black,double,cloud,fill=black!75, inner sep=-16pt, cloud puffs=14, aspect=2, rotate=-60, text width=4.5cm] {\color{white}Some interesting \textbf{text} with an equation in it $x^2+5x-3=0$}
    }
    child[colleague, grow=-90, level distance=45mm] {node[draw=black,double,cloud,fill=black!75, inner sep=-40pt, cloud puffs=20, aspect=5, text width=8.5cm] {\color{white}Some important details here plus a bit of controversy to spark a discussion for example}
    }
    child[partner, grow=150, level distance=40mm] {node[draw=black,double,cloud,fill=black!75, inner sep=-2pt, cloud puffs=8, aspect=2, rotate=57, text width=2.5cm] {\color{white}Last piece of text that people have to deal with}
    };
    \end{scope}

    \end{tikzpicture}
\end{document}

结果:

在此处输入图片描述

答案1

我对您的问题的解释如下:您想要将云和文本变形,使得云的长轴(解释为椭圆)位于以“大文本”节点为中心的圆上,对吗?如果是这样,那么我相信已经取得了一些进展。但是,解决方案仍缺少几个步骤,因此我想与您确认这是否是您想要的。

假设是,我们可以使用非线性变换。考虑这个例子:

\documentclass{article}
\usepackage{tikz}
\usepgfmodule{nonlineartransformations}
\usetikzlibrary{shapes}
\usetikzlibrary{patterns}
\newcommand{\mytypeout}[1]{\relax}
\makeatletter
% from https://tex.stackexchange.com/q/56353/121799
\newcommand{\gettikzxy}[3]{%
  \tikz@scan@one@point\pgfutil@firstofone#1\relax
  \edef#2{\the\pgf@x}%
  \edef#3{\the\pgf@y}%
}
% from the manual section 103.4.2
% \pgf@x will contain the \xout{radius} angle
% \pgf@y will contain the distance \pgfmathsincos@{\pgf@sys@tonumber\pgf@x}%
% pgfmathresultx is now the cosine of \xout{radius} radius and 
% pgfmathresulty is the sine of radius 
% \pgf@x=\pgfmathresultx\pgf@y% 
% \pgf@y=\pgfmathresulty\pgf@y%
% what the thing in the pgf manually is probably doing it to express the x coordinate in pt
% then take the cos and sin of x/pt (i.e. if x=50pt then it will return cos(50))
% and multiply the outcome by a the y coordinate
% (x_new,y_new) = (y_old cos(x_old/pt), y_old sin(x_old/pt))
% now comes a slightly modified version
\def\marmotransformation{% modified version of the manual 103.4.2 Installing Nonlinear Transformation
\mytypeout{before:\space\the\pgf@x\space\the\pgf@y\space\xC\space\yC}%
\edef\oriX{\the\pgf@x}%
\edef\oriY{\the\pgf@y}%
\mytypeout{original\space x=\oriX\space y=\oriY}
\advance\pgf@x by -\xC% relative
\advance\pgf@y by -\yC% coorinates
\edef\relX{\the\pgf@x}%
\edef\relY{\the\pgf@y}% Yes, there is a more elegant solution based on \pgfpointadd
\mytypeout{xrel=\relX\space yrel=\relY}%
\pgfmathsetmacro{\relNx}{\xN-\xC}%
\pgfmathsetmacro{\relNy}{\yN-\yC}%
\pgfmathtruncatemacro{\testNx}{\xN-\xC}%
\pgfmathtruncatemacro{\testNy}{\yN-\yC}%
\ifnum\testNx=0\relax
\ifnum\testNy>0\relax
\pgfmathsetmacro{\angleN}{90}%
\else
\pgfmathsetmacro{\angleN}{-90}%
\fi
\else
\pgfmathsetmacro{\angleN}{atan(\relNy/\relNx)}%
\fi
\pgfmathsetmacro{\LeN}{sqrt((\relNx)^2+(\relNy)^2)}%
\mytypeout{relNx=\relNx,\space relNy=\relNy,\space LeN=\LeN,\space angleN=\angleN}%
\pgfmathsetmacro{\myp}{(\relX*\relNx+\relY*\relNy)/(\LeN*28.3465)}
\pgfmathsetmacro{\myo}{(((\relY*\relNx-\relX*\relNy))/(5*28.3465)+\angleN)}
\mytypeout{new\space p=\myp,\space o=\myo}
\pgfpointadd{\pgfqpoint{\xC}{\yC}}{\pgfpointpolarxy{\myo}{\myp}}
\mytypeout{after:\space\the\pgf@x\space\the\pgf@y}%
} % I have no idea why the factor 5 is needed
% I'm using https://tex.stackexchange.com/a/167109/121799
\begin{document}
\noindent
\begin{minipage}{9cm}
In order to set the problem up properly, let's have a look at the picture on the
right. There is a center $C$, which corresponds to center of the ``Big text''
node in your example, and the coordinate $N$, which corresponds to the center of
a given cloud that is to be deformed, i.e.\ the fixed point of the
transformation. We are now looking for a transformation
that maps the blue line to the red line. Consider a point $P$ with coordinates
$(x_P,y_P)$. We can decompose its coordinates into a part $p$ that is parallel to the line
$CN$ and an orthogonal part $o$,
\begin{eqnarray*} % I'm using archaic environments here because I don't want to load more packages than absolutely necessary
 p & = &\frac{\displaystyle(x_P-x_O,y_P-y_O)\cdot
 \left(\begin{array}{c}x_N-x_O\\ y_N-y_O\end{array}\right)}{\sqrt{(x_N-x_O,y_N-y_O)\cdot(x_N-x_O,y_N-y_O)}}
\;,\\
 o & = &
 \frac{\displaystyle(y_P-y_O,x_O-x_P)\cdot
 \left(\begin{array}{c}x_N-x_O\\ y_N-y_O\end{array}\right)}{\sqrt{(x_N-x_O,y_N-y_O)\cdot(x_N-x_O,y_N-y_O)}}
 \;.
\end{eqnarray*}
$P'$ has then the polar coordinates 
\[P'\colon \left(\frac{360}{2\pi}\frac{o}{p}\colon p\right)
\quad\mbox{with}~\frac{360}{2\pi}~=~57.2985
\;.\]
\end{minipage}\hspace*{1cm}%
\begin{minipage}{5cm}
\begin{tikzpicture}
 \node[circle,fill,scale=0.4,draw,label=below:$C$] (C) at (0,0) {};
 \node[circle,fill,scale=0.4,draw,label=above:$N$] (N) at (2,4) {};
 \draw[thick,-,blue] (0,5)-- (4,3);
 \draw[dashed,-] (C) -- (N);
 \draw[-,thick,red] (N) arc[radius={2*sqrt(5)}, start angle=63.4, end angle=93.4];
 \draw[-,thick,red] (N) arc[radius={2*sqrt(5)}, start angle=63.4, end angle=33.4];
 \node[circle,fill,scale=0.4,draw,label=above:\textcolor{blue}{$P$},blue] (P) at (1,4.5) {};
 \node[circle,fill,scale=0.4,draw,label=below:\textcolor{red}{$P'$},red] (Pp) at (78.4:{2*sqrt(5)}) {};
\end{tikzpicture}
\end{minipage}\\
\begin{tikzpicture}
\node at (-6,5) {original};
\node[draw,
    cloud,
    cloud puffs = 10,
    pattern=north east lines,
    minimum width=5cm,
    minimum height=2.75cm,
] at (-6,3){};
\draw[-,blue](-8,3)--(-4,3);
\node[circle,fill,scale=0.4,draw,label=below:$C$] (oriC) at (-6,0) {};
\node[circle,fill,scale=0.4,draw,label=above:$N$] (oriN) at (-6,3) {};
%
\node at (0,5) {transform};
\node[circle,fill,scale=0.4,draw,label=below:$C$] (C) at (0,0) {};
\gettikzxy{(C)}{\xC}{\yC}
\node[circle,fill,scale=0.4,draw,label=above:$N$] (N) at (0,3) {};
\gettikzxy{(N)}{\xN}{\yN}
\begin{scope}[transform shape nonlinear=true]
\pgftransformnonlinear{\marmotransformation} 
\node[draw, cloud,
    cloud puffs = 10,
    pattern=north east lines,
    minimum width=5cm,
    minimum height=2.75cm,
] at (0,3){};
\draw[-,blue](-2,3)--(2,3);
\end{scope}
\end{tikzpicture}
\clearpage

Of course, if one sets the fixed point node $N$ differently, the outcome will change.\\*
\begin{tikzpicture}
\node at (-6,5) {original};
\node[draw,
    cloud,
    cloud puffs = 10,
    pattern=north east lines,
    minimum width=5cm,
    minimum height=2.75cm,
] at (-6,3){};
\draw[-,blue](-8,3)--(-4,3);
\node[circle,fill,scale=0.4,draw,label=below:$C$] (oriC) at (-7,0) {};
\node[circle,fill,scale=0.4,draw,label=above:$N$] (oriN) at (-6,3) {};
%
\node at (0,5) {transform};
\node[circle,fill,scale=0.4,draw,label=below:$C$] (C) at (-1,0) {};
\gettikzxy{(C)}{\xC}{\yC}
\node[circle,fill,scale=0.4,draw,label=above:$N$] (N) at (0,3) {};
\gettikzxy{(N)}{\xN}{\yN}
\begin{scope}[transform shape nonlinear=true]
\pgftransformnonlinear{\marmotransformation} 
\node[draw,
    cloud,
    cloud puffs = 10,
    pattern=north east lines,
    minimum width=5cm,
    minimum height=2.75cm,
] at (0,3){};
\draw[-,blue](-2,3)--(2,3);
\end{scope}
\end{tikzpicture}


An unsolved problem is how to deal with additional tranformations.\\*
\begin{tikzpicture}
\node at (-6,5) {original};
\node[draw,
    cloud,
    cloud puffs = 10,
    pattern=north east lines,
    minimum width=5cm,
    minimum height=2.75cm,
] at (-6,3){};
\draw[-,blue](-8,3)--(-4,3);
\node[circle,fill,scale=0.4,draw,label=below:$C$] (oriC) at (-7,0) {};
\node[circle,fill,scale=0.4,draw,label=above:$N$] (oriN) at (-6,3) {};
%
\node at (0,5) {transform};
\node[circle,fill,scale=0.4,draw,label=below:$C$] (C) at (-1,0) {};
\gettikzxy{(C)}{\xC}{\yC}
\node[circle,fill,scale=0.4,draw,label=above:$N$] (N) at (0,3) {};
\gettikzxy{(N)}{\xN}{\yN}
\begin{scope}[transform shape nonlinear=true,rotate=-120]
\pgftransformnonlinear{\marmotransformation} 
\node[draw,cloud,
    cloud puffs = 10,
    pattern=north east lines,
    minimum width=5cm,
    minimum height=2.75cm,
] at (0,3){};
\draw[-,blue](-2,3)--(2,3);
\end{scope}
\end{tikzpicture}\\*
This is not so much a problem caused by the nonlinearity of the transformation.
Rather I do not know yet how to tell Ti$k$Z in which order the transformations
are to be done. The same thing happens with linear transformations, e.g.\ when
combining rotations and translations.
\end{document}  

在此处输入图片描述

它确实会以类似于您想要的方式变形云。通过调整原点C和固定点的位置N,您可以修改结果。目前有两个弱点,阻止我将其应用于您的示例。首先,我没有告诉 TiZ 执行转换的顺序。其次,当前定义C和的方式N不太优雅。

相关内容