使用 TikZ 绘制这张图片?

使用 TikZ 绘制这张图片?

我需要画下面的图,有谁能帮我吗?我从来没有用过 TikZ,所以我真的不知道怎么画!

在此处输入图片描述

答案1

我也是 TikZ 的新手。这是我第三次使用它。我一边阅读手册一边尝试解决你的问题。这很有趣,尤其是当我设法掌握它时。

\documentclass[a4paper,draft]{article}
\usepackage{tikz}

%% Define a style for the boxes.
\tikzset{boxes/.style={ultra thick, rounded corners=5pt,black}}
\tikzset{aline/.style={>=stealth},
         aline/.default=black}
\tikzset{sbox/.style={thick,rounded corners=2pt,draw=white,fill=white}}
\tikzset{oval/.style={fill=white,}}

\begin{document}
\begin{tikzpicture}[scale=0.05]
  % Draw the long red (starting) line
  \draw[aline,red, ->] (25,195) -- (25,150);
  % and insert the labeling text
  \draw(25,195) node[left]{\parbox{2cm}{\raggedleft
      Original\\secret}} node[right] {$\Psi$};
  % the text above the top arrows
  \draw(50,175) node[above] {ancillary states};
  % Draw the next, normal black lines, each 10 mm apart from each
  % other
  \foreach \x in {10, 20, ..., 50}
     \draw[aline,->] (25+\x,175) -- (25+\x,150);
  % draw the Box with the label AI   
  \draw[boxes] (20,130) rectangle +(60,20);
  \draw(50,140) node {\textbf{AI}};
  % draw a circle around the box
  \draw[blue] (50,140) ellipse [x radius=50, y radius=20];
  \draw (90,155)  node[right] {\textcolor{blue}{dealer}};
  % Draw the first two lines, that end in "n Shares" box
  \foreach \x in {0,10}
     \draw [aline] (25+\x,130) -- (25+\x,100);
  % Draw the next bunch of lines, that end in the lower AI box.
  \foreach \x in {20, 30, ..., 50}
     \draw[aline,->] (25+\x,130) -- (25+\x,60);
  % Draw the lower AI box.  You can also calculate the coordinates
  \draw[boxes] (35,40) rectangle +(50,20);
  \draw(35+25,40+10) node{\textbf{AI}};
  % draw another ellipse around the box
  \draw[blue] (60,50) ellipse [x radius=45, y radius=18];
  \draw (100,60)  node[right] {\parbox{3cm}{\color{blue} $k$
      collaborating\\\hspace*{3mm}players}};
 % Draw the last lines.  One long and three shorter ones
  \foreach \x in {10, 20, 30}
      \draw[aline,->] (45+\x,40) -- (45+\x,25);
  \draw[aline,red,->] (45,40) -- (45,5);
  % and mount the label to it
  \draw(45,5) node[left] {\parbox{2cm}{\raggedleft
      replicated\\secret}} node [right]{$\Psi$};
  % Lay another box over the image, clipping  the vertical lines of
  \draw[sbox] (20,100) rectangle (80,110);
  \draw(50,105) node {$n$ Shares};
\end{tikzpicture}
\end{document}

导致

在此处输入图片描述

当然,欢迎您根据您的需要调整样式等。

相关内容