如何管理旋转矩形的定位

如何管理旋转矩形的定位

如何在这张图片中绘制这两个矩形:

在此处输入图片描述

我尝试过这样的:

\documentclass[border=10pt]{standalone}
%\usepackage[margin=1cm]{geometry}
\usepackage{tikz,xcolor}
\usetikzlibrary{shapes.geometric,arrows,positioning,fit,calc,}
\tikzset{
b/.style={draw, rectangle, rounded corners=2ex,minimum height=0.5in, minimum width=2in,align=center},
c/.style={draw, rectangle, rounded corners=2ex, minimum height=0.5in, minimum  width=2in,align=center, rotate=-90},
ar/.style={rounded corners=2ex,->,>=latex },  
myarrow/.style args={#1 colored by #2 and #3}{
    -stealth,line width=#1,#2,postaction={draw,-stealth,#3,line width=(#1)/3,
    shorten <=(#1)/3,shorten >=2*(#1)/3}, 
  }
}

\begin{document}
\begin{tikzpicture} 
       \node (client) [c] {Client};
       \node (serveur) [c, below=3 cm of client] {Serveur};

  \end{tikzpicture}

\end{document}

结果如下:

在此处输入图片描述

我对定位有疑问。请解释一下你的代码,不要只给出代码。

答案1

用作节点north east的锚点survey并将其放置在左侧 3cm 处client.south east

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\tikzset{
  c/.style={
    draw,rectangle,rounded corners=2ex,
    minimum height=0.5in, minimum  width=2in,
    align=center,
    rotate=-90
  }
}

\begin{document}
\begin{tikzpicture} 
  \node (client) [c] {Client};
  \node (serveur) [c,
    left=3 cm of client.south east,anchor=north east
    % inserts the north east anchor of serveur 3cm left of client.south east,
    % rotation center ist north east of serveur
  ] {Serveur};
\end{tikzpicture}
\end{document}

在此处输入图片描述

下面的图片解释了发生了什么:

在此处输入图片描述

代码:

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\tikzset{
  c/.style={
    draw,rectangle,% rounded corners=2ex,
    minimum height=0.5in, minimum  width=2in,
    align=center,
    %rotate=-90
  }
}

\begin{document}
\begin{tikzpicture}[every label/.style={font=\tiny}]

  \node (client) [c,rotate=-90] {Client};
  \node [blue,pin={[blue,font=\tiny]below:client.south east}]at(client.south east){x};
%
  \draw [green!50!black,dashed,-latex](client.south east)--+(-3,0);
%
  \node (unrotated) 
    [red,c, left=3 cm of client.south east,anchor=north east] {unrotated};
  \node [red,label={[red]below right:unrotated.north east}]at(unrotated.north east){x};
  \draw [red,-latex](unrotated.north east)+(-135:0.5)arc(-135:-235:0.5);
%
  \node (serveur) 
    [c, left=3 cm of client.south east,anchor=north east,rotate=-90] {Serveur};
  \node [draw=green!50!black,circle,
    label={[green!50!black]above right:serveur.north east}]at(serveur.north east){};
\end{tikzpicture}
\end{document}

相关内容