是否可以将图像作为背景图案插入到思维导图节点?

是否可以将图像作为背景图案插入到思维导图节点?

假设我有以下思维导图:

\documentclass[margin=10pt]{standalone}
\usepackage[dvipsnames,svgnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{mindmap,trees,shadows}
\usepackage{fontspec}

\begin{document}
    \begin{tikzpicture}
      [mindmap,
      font=\large\bfseries\sffamily,
      grow cyclic,
every node/.style={concept, circular drop shadow, 
    %minimum size=0pt,
    execute at begin node=\hskip0pt},
      %concept color=magenta!70!black,
      root concept/.append style={
        font=\huge\sffamily\bfseries,text width=8cm,concept color=Gold},
      level 1/.append style={sibling angle=360/10,
        font=%\color{Seashell}
        \bfseries\sffamily
        \LARGE,
        level distance=35em,
        inner sep=0pt,
        text width=4cm,
        sibling distance=1cm,
        concept color=Goldenrod},
      level 2/.append style={%sibling angle=37.5,
        sibling distance=21em,
        font=\color{Seashell}\sffamily\bfseries\fontsize{36pt}{48pt}\selectfont,level distance=10cm,inner sep=0pt,text width=7cm,color=purple!50},
]

         \node [root concept] {Root Concept}
         child {node {Node}}
         child {node {Node}}
         child {node {Node}}
         child {node {Node}}
child {node {Node}}
child {node {Node}}
child {node {Node}}
child {node {Node}}
child {node {Node}}
child {node {Node}};
  \end{tikzpicture}
\end{document}

在此处输入图片描述

很好,但我想知道是否有可能为这些节点实现“纹理”背景,因为其他 tikz 节点也可以实现这里

答案1

是的。实现此目的的一种方法是将 放入path picturenodes,并确保放入 中的节点path picture看不到选项,这可以通过在本地设置 来实现every node/.style={}

\documentclass[margin=10pt]{standalone}
\usepackage[dvipsnames,svgnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{mindmap,trees,shadows}
\usepackage{fontspec}

\begin{document}
    \begin{tikzpicture}
      [mindmap,
      font=\large\bfseries\sffamily,
      grow cyclic,
every node/.style={concept, circular drop shadow, 
    %minimum size=0pt,
    execute at begin node=\hskip0pt},
      %concept color=magenta!70!black,
      root concept/.append style={
        font=\huge\sffamily\bfseries,text width=8cm,concept color=Gold},
      level 1/.append style={sibling angle=360/10,
        font=%\color{Seashell}
        \bfseries\sffamily
        \LARGE,
        level distance=35em,
        inner sep=0pt,
        text width=4cm,
        sibling distance=1cm,
        concept color=Goldenrod,
        nodes={%
            fill=none,draw,
            path picture={\node[every node/.style={}] at (path picture bounding box.center) 
                {\includegraphics[width=4cm,height=4.1cm]{example-image-duck}};},%},
            },      
        },
      level 2/.append style={%sibling angle=37.5,
        sibling distance=21em,
        font=\color{Seashell}\sffamily\bfseries\fontsize{36pt}{48pt}\selectfont,level distance=10cm,inner sep=0pt,text width=7cm,color=purple!50},
]

         \node [root concept] {Root Concept}
         child {node {Node}}
         child {node {Node}}
         child {node {Node}}
         child {node {Node}}
child {node {Node}}
child {node {Node}}
child {node {Node}}
child {node {Node}}
child {node {Node}}
child {node {Node}};
  \end{tikzpicture}
\end{document}

在此处输入图片描述

如果你example-image-duckGoldLeaf.jpgfrom替换这里你得到

在此处输入图片描述

如果您想让更多级别的节点变为金色,您可能需要为其定义一种样式。

\documentclass[margin=10pt]{standalone}
\usepackage[dvipsnames,svgnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{mindmap,shadows}
\usepackage{fontspec}
\tikzset{golden/.style={
          fill=none,draw,
          path picture={\node[every node/.style={}] at (path picture bounding box.center) 
              {\includegraphics[width=#1,height=#1]{GoldLeaf.jpg}};},%},
          },golden/.default=4cm         
}

\begin{document}
    \begin{tikzpicture}[mindmap,
      font=\large\bfseries\sffamily,
      grow cyclic,
    every node/.style={concept, circular drop shadow, 
    %minimum size=0pt,
    execute at begin node=\hskip0pt},
      %concept color=magenta!70!black,
      root concept/.append style={
        font=\huge\sffamily\bfseries,text width=8cm,concept color=Gold,
        golden=8cm},
      level 1/.append style={sibling angle=360/10,
        font=%\color{Seashell}
        \bfseries\sffamily
        \LARGE,
        level distance=35em,
        inner sep=0pt,
        text width=4cm,
        sibling distance=1cm,
        concept color=Goldenrod,nodes={golden=4cm}
        }]

         \node [root concept] {Root Concept}
         child {node {Node}}
         child {node {Node}}
         child {node {Node}}
         child {node {Node}}
child {node {Node}}
child {node {Node}}
child {node {Node}}
child {node {Node}}
child {node {Node}}
child {node {Node}};
\end{tikzpicture}
\end{document}

在此处输入图片描述

请注意,如果您也想让连接条遵循该模式,那么最好采用不同的方法path fading,我很乐意在另一天详细说明。

相关内容