TikZ로 이 그래픽을 만드는 방법은 무엇입니까?

TikZ로 이 그래픽을 만드는 방법은 무엇입니까?

다음과 같은 그래픽을 만들고 싶습니다.

여기에 이미지 설명을 입력하세요

아래는 내 코드입니다.

    \documentclass[11pt]{article}
    \usepackage{tikz}
    \usetikzlibrary{arrows}

    \newcommand{\psign}{+}
    \newcommand{\ppsign}{++}

    \begin{document}

    \noindent
    \begin{tikzpicture}
    \tikzstyle{my node} = [draw,rectangle,minimum width=2.2cm,minimum height=0.8cm, node distance=2cm]
    %\draw[black!20] (-0.5cm,-0.5cm) grid (14cm,7cm);
    \node [my node] (A) {GDI DDI};
    \node [my node] (B) [above of=A] {GDI};

    \begin{scope}[xshift=3cm]
    \node                       (C)     {Graphics Driver};
    \node [my node] (D) [above of=C]    {GDI\psign Flat API};
    \node [my node] (E) [above of=D]    {GDI\psign\ C\ppsign API};
    \end{scope}

    \begin{scope}[xshift=6cm]
    \node [my node] (F) {DX DDI};
    \node [my node] (G) [above of=F] {DXGI};
    \node [my node] (H) [above of=G] {Direct3D};
    \node [my node] (I) [above of=H,minimum width=4cm,right=0pt] {Direct2D};
    \node [my node] (J) [right of=I,right=0pt,node distance=3cm] {DirectWrite};
    \node [my node] (K) [right of=F, node distance=4cm] {Software Rasterizer};
    \end{scope}

    \begin{scope}[->,>=triangle 45,semithick]
    \path (B) edge (A);
    \path (E) edge (D);
    \path (H) edge (G);
    \path (G) edge (F);
    \path (J) edge (I);
    \end{scope}

    \draw [dashed] (-1.25,1cm) -- (14,1cm);
    \end{tikzpicture}

    \end{document}

답변1

여기에 이미지 설명을 입력하세요

\documentclass[11pt]{article}
\usepackage{tikz,xcolor}
\usetikzlibrary{arrows,calc,fit,backgrounds}

\definecolor{fcolor}{HTML}{F1F1F1}

\newcommand{\psign}{+}
\newcommand{\ppsign}{++}

\begin{document}

\noindent
\begin{tikzpicture}
\tikzstyle{my node} = [draw,rectangle,minimum width=2.2cm,minimum height=0.8cm, node distance=2cm]
%\draw[black!20] (-0.5cm,-0.5cm) grid (14cm,7cm);
\node [my node] (A) {GDI DDI};
\node [my node] (B) [above of=A] {GDI};

\begin{scope}[xshift=3cm]
\node                       (C)     {Graphics Driver};
\node [my node] (D) [above of=C]    {GDI\psign Flat API};
\node [my node] (E) [above of=D]    {GDI\psign\ C\ppsign API};
\end{scope}

\begin{scope}[xshift=6cm]
\node [my node] (F) {DX DDI};
\node [my node] (G) [fill=white,above of=F] {DXGI};
\node [my node] (H) [fill=white,above of=G] {Direct3D};
\node [my node] (I) [fill=white,above of=H,minimum width=4.5cm,right=0pt] {Direct2D};
\node [my node] (J) [fill=white,right of=I,right=0pt,node distance=3.5cm] {DirectWrite};
\node [my node] (K) [fill=white,right of=G, node distance=4cm] {Software Rasterizer};
\end{scope}

\begin{scope}[->,>=triangle 45,semithick]
\path (B) edge (A);
\path (E) edge (D);
\path (H) edge (G);
\path (G) edge (F);
\path (J) edge (I);
\path (I.south-|K) edge (K);
\path (I.south-|{$(H.north)!.5!(H.north east)$}) edge ($(H.north)!.5!(H.north east)$);
\end{scope}

\begin{scope}[on background layer]
\node[rectangle,fill=fcolor,fit=(G.south west) (J.north east)] {};
\end{scope}

\draw [dashed] (-1.25,1cm) -- (14,1cm);
\end{tikzpicture}

\end{document}

Software Rasterizer먼저 노드 배치를 수정했습니다 right of=G.

\node [my node] (K) [right of=G, node distance=4cm] {Software Rasterizer};

그런 다음 나머지 두 개의 화살표 연결에 대해 edge다음 두 줄을 추가했습니다.

\path (I.south-|K) edge (K);
\path (I.south-|{$(H.north)!.5!(H.north east)$}) edge ($(H.north)!.5!(H.north east)$);

여기에는 노드 중심 바로 위에 있는 노드 (I.south-|K)의 점이 있습니다 . 에 대해서도 같은 아이디어 이지만 약간 복잡합니다. 이제 이는 노드 의 북쪽과 북동쪽 사이의 중간 지점 바로 위에 있는 노드 의 지점입니다 .Direct2DSoftware Rasterizer(I.south-|{$(H.north)!.5!(H.north east)$})Direct2DDirect3D

강조 표시된 5개 블록은 라이브러리에서 얻을 수 있지만 fit이번에는 on background layer노드를 두 번 그리는 것을 피하기 위해 범위( ) 내에서 얻을 수 있습니다. G및 와 같은 두 개의 가장 바깥쪽 노드를 선택 J하고 각각의 가장 바깥쪽 모서리 (G.south west)및 를 지정합니다 (J.north east).

답변2

이런 종류의 작업은 당신이 찾고 있는 일을 합니다. 맨 위에 그리는 점에 유의하세요 fit. 아래에 풀 컬러가 필요한 경우 해당 노드를 두 번 그려야 할 수도 있습니다(한 번은 계산을 위한 노드를 가져오고 fit한 번은 맞춤 영역에 다시 그리려면 해당 노드를 저장하면 됩니다). 매크로에 코드를 그리고 해당 매크로를 두 번 실행합니다.

\documentclass[11pt]{article}
  \usepackage{tikz}
  \usetikzlibrary{arrows,calc}
  \usetikzlibrary{positioning,fit}
    \newcommand{\psign}{+}
    \newcommand{\ppsign}{++}

    \begin{document}

    \noindent
    \begin{tikzpicture}
    \tikzstyle{my node} = [draw,rectangle,minimum width=2.2cm,minimum height=0.8cm, node distance=2cm]
    %\draw[black!20] (-0.5cm,-0.5cm) grid (14cm,7cm);
    \node [my node] (A) {GDI DDI};
    \node [my node] (B) [above of=A] {GDI};

    \begin{scope}[xshift=3cm]
    \node                       (C)     {Graphics Driver};
    \node [my node] (D) [above of=C]    {GDI\psign Flat API};
    \node [my node] (E) [above of=D]    {GDI\psign\ C\ppsign API};
    \end{scope}

    \begin{scope}[xshift=6cm]
    \node [my node] (F) {DX DDI};
    \node [my node] (G) [above of=F] {DXGI};
    \node [my node] (H) [above of=G] {Direct3D};
    \node [my node] (I) [above of=H,minimum width=4cm,right=0pt] {Direct2D};
    \node [my node] (J) [right of=I,right=0pt,node distance=3cm] {DirectWrite};
    \node [my node] (K) [right of=G, node distance=4cm] {Software Rasterizer};
    \end{scope}


  \begin{scope}[ transform canvas={xshift=1cm},
    ->,>=triangle 45,semithick]
    \draw (I)  --  (I |- K.north);
  \end{scope}
  \begin{scope}[ transform canvas={xshift=-4em},
    ->,>=triangle 45,semithick]
    \draw (I)  --  (I |- H.north);
  \end{scope}

    \begin{scope}[->,>=triangle 45,semithick]
    \path (B) edge (A);
    \path (E) edge (D);
    \path (H) edge (G);
    \path (G) edge (F);
    \path (J) edge (I);
    \end{scope}

    \draw [dashed] (-1.25,1cm) -- (14,1cm);


    \node [fill=gray,opacity=0.2,dotted,fit = (H) (I) (J) (K) ] {};



    \end{tikzpicture}

    \end{document}

여기에 이미지 설명을 입력하세요

회색 영역 위에 범례를 추가하는 방법을 알아낼 수 있다고 가정합니다.

답변3

@daleif 및 @AboAmmar 솔루션을 단순화하여 약간 수정했습니다(거의 동일한 것 같습니다 :-)).

\documentclass[11pt, border=1mm,
               tikz,
               preview]{standalone}
\usetikzlibrary{arrows,calc,fit,backgrounds}
    \newcommand{\psign}{+}
    \newcommand{\ppsign}{++}

    \begin{document}
\begin{tikzpicture}[
    node distance = 2cm,
every node/.style = {draw, rectangle,
                    fill=white, % if you liked, otherwise should be omitted
                     minimum width=2.2cm, minimum height=0.8cm}
                    ]
\node  (A) {GDI DDI};
\node  (B) [above of=A] {GDI};

\begin{scope}[xshift=3cm]
\node  (C) [draw=none]     {Graphics Driver};
\node  (D) [above of=C]    {GDI\psign Flat API};
\node  (E) [above of=D]    {GDI\psign\ C\ppsign API};
\end{scope}

\begin{scope}[xshift=6cm]
\node  (F) {DX DDI};
\node  (G) [above of=F] {DXGI};
\node  (H) [above of=G] {Direct3D};
\node  (I) [above of=H,minimum width=4.5cm,right=0pt] {Direct2D};
\node  (J) [right of=I,right=0pt,node distance=3.5cm] {DirectWrite};
\node  (K) [right of=G, node distance=4cm] {Software Rasterizer};
\end{scope}

\coordinate (L) at ([xshift=7mm] H.north);
\path[-triangle 45,semithick]
    (B) edge (A)    (E) edge (D)    (H) edge (G)
    (G) edge (F)    (J) edge (I)    (I.south-|K) edge (K)
    (I.south -| L) edge (L)
    (I.south-|{$(H.north)!.5!(H.north east)$}) -- ($(H.north)!.5!(H.north east)$);

\scoped[on background layer]
    \node (M) [rectangle,fill=gray!30,fit=(G.south west) (J.north east)] {};

\coordinate (N) at ($(A.west)!0.5!(B.west)$);
\draw [dashed]  (N) -- (N -| M.east);
\end{tikzpicture}
        \end{document}

이 코드는 다음을 제공합니다.

여기에 이미지 설명을 입력하세요

관련 정보