tikz,装饰路径和模糊效果

tikz,装饰路径和模糊效果

我想添加下图所示的装饰,在乘号下方添加模糊效果。

在此处输入图片描述

这是我的起始代码。

\documentclass[12pt]{article}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
    \matrix[
        row sep    = 1em,
        column sep = 1.5em,
        block/.style={
             rectangle,
             draw=blue,
             thick,
             fill=blue!20,
             text width=5em,
             align=center,
             rounded corners,
             minimum height=2em
        },
    ]{
                            & \node {$9665$};      &                \\
        \node[block] {$2$}; & \node {$488888887$}; & \node[block] {$3$};   \\
                            & \node {$777$};       & \node[block] {$11$};  \\
                            &                      & \node {$99$};  \\
      };
\end{tikzpicture}

\end{document}

答案1

无数种可能的方法中的两种都可以实现这样的效果。这将使用matrix库来简化矩阵和普通循环节点或带有path pictures 的节点的处理。

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}

\begin{tikzpicture}[X/.style={circle,draw,fill=white,inner sep=1pt}]
    \matrix[matrix of nodes,
        row sep    = 1em,
        column sep = 1.5em,
        block/.style={
             rectangle,
             draw=blue,
             thick,
             fill=blue!20,
             text width=5em,
             align=center,
             rounded corners,
             minimum height=2em
        },
    ](mat){
                            &  9665      &                \\
        |[block]| 2 &  488888887 & |[block]| 3   \\
                            &  777       & |[block]| 11  \\
                            &                      &  99  \\
      };
\draw[red] (mat-2-1) -- (mat-2-3) node[midway,draw,X,opacity=0.6]{$\times$};
\draw[red,-latex] (mat-2-3.east) -| ++ (1,1) coordinate[pos=0.5] (aux) -- ++ (-1,0);
\draw[red] (mat-3-3.east) -| (aux) node[pos=0.75,draw,X,opacity=0.6]{$+$};
\end{tikzpicture}

\begin{tikzpicture}[X/.style={circle,draw,fill=white,minimum size=1.4em,
path picture={
\draw (path picture bounding box.north west) --
(path picture bounding box.south east) 
(path picture bounding box.north east) -- 
(path picture bounding box.south west); }},
Plus/.style={circle,draw,fill=white,minimum size=1.4em,
path picture={
\draw (path picture bounding box.west) --
(path picture bounding box.east) 
(path picture bounding box.north) -- 
(path picture bounding box.south); }}]
    \matrix[matrix of nodes,
        row sep    = 1em,
        column sep = 1.5em,
        block/.style={
             rectangle,
             draw=blue,
             thick,
             fill=blue!20,
             text width=5em,
             align=center,
             rounded corners,
             minimum height=2em
        },
    ](mat){
                            &  9665      &                \\
        |[block]| 2 &  488888887 & |[block]| 3   \\
                            &  777       & |[block]| 11  \\
                            &                      &  99  \\
      };
\draw[red] (mat-2-1) -- (mat-2-3) node[midway,draw,X,opacity=0.6]{};
\draw[red,-latex] (mat-2-3.east) -| ++ (1,1) coordinate[pos=0.5] (aux) -- ++ (-1,0);
\draw[red] (mat-3-3.east) -| (aux) node[pos=0.75,draw,Plus,opacity=0.6]{};
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容