\filldraw 不填充

\filldraw 不填充

我的论文中有一张图,我在其中讨论了基本颜色概念和指南针的相似之处。原始图像是我在 Paint 中粗略拼凑起来的,但我认为我可以通过粗略拼凑一些东西来使它变得更好一些tikz。这是原始图像: 色谱作为指南针 我的计划是最终得到类似这样的结果,但目前我陷入了困境,因为我试图用黑色填充的区域无法填充,我不知道我做错了什么。目前它看起来是这样的: 指南针的进展

我希望两条北线之间的区域被涂成黑色。这是我的代码:

\documentclass{book}
\usepackage{tikz}
\usetikzlibrary {decorations.pathmorphing}
\begin{document}

\begin{tikzpicture}[inner sep=0,outer sep=0,]

    % circles (from centre)
    \node[thick,draw=black,circle,
        minimum size=1cm,
        decorate,
        decoration={random steps,segment length=1.5pt,amplitude=0.2pt}] (centre) at (0,0) {};
        
    \node[thick,draw=black,circle,
        minimum size=4.5cm,
        decorate,
        decoration={random steps,segment length=1.5pt,amplitude=0.2pt}] (inedge) at (0,0) {};
        
    \node[thick,draw=black,circle,
        minimum size=5cm,
        decorate,
        decoration={random steps,segment length=1.5pt,amplitude=0.2pt}] (outedge) at (0,0) {};
    
    % main direction nodes
    \begin{scope}[label distance=0.5cm]
    % North
    \node[thick,draw=black,circle,
        minimum size=0.3cm,
        label=above:\Large{$\mathcal{N}$}] (N) at (0,3.5) {};
        
        \node[circle,draw=black,fill=black,
        minimum size=1.5mm] (n) at (0,3.5) {};
    % East  
    \node[thick,draw=black,circle,
        minimum size=0.3cm,
        label=right:\Large{$\mathcal{E}$}] (E) at (3.5,0) {};
        
        \node[circle,draw=black,fill=black,
        minimum size=1.5mm] (e) at (3.5,0) {};
    % South
    \node[thick,draw=black,circle,
        minimum size=0.3cm,
        label=below:\Large{$\mathcal{S}$}] (S) at (0,-3.5) {};
        
        \node[circle,draw=black,fill=black,
        minimum size=1.5mm] (s) at (0,-3.5) {};
    % West  
    \node[thick,draw=black,circle,
        minimum size=0.3cm,
        label=left:\Large{$\mathcal{W}$}] (W) at (-3.5,0) {};
        
        \node[circle,draw=black,fill=black,
        minimum size=1.5mm] (w) at (-3.5,0) {};
    \end{scope}
    
    % mainlines
    \draw[thick,
        decorate,
        decoration={random steps,segment length=3pt,amplitude=0.1pt}]
        (centre) -- (N);
        
    \draw[thick,
        decorate,
        decoration={random steps,segment length=3pt,amplitude=0.1pt}]
        (centre) -- (E);

    \draw[thick,
        decorate,
        decoration={random steps,segment length=3pt,amplitude=0.1pt}]
        (centre) -- (S);

    \draw[thick,
        decorate,
        decoration={random steps,segment length=3pt,amplitude=0.1pt}]
        (centre) -- (W);

    % Main points
    \filldraw[black] (-0.35cm,0.35cm) -- (N) -- (centre) -- cycle; % why u no fill?!!

\end{tikzpicture}

\end{document}

我确实意识到我的代码非常重复,但我既尝试定义各个方面,tikzpicture又创建了一个/.style,但没有成功,所以我决定这样做,以便它起作用,并在我弄清楚所有细节后再清理它。

答案1

您应该使用坐标而不是节点:

\documentclass{book}
\usepackage{tikz}
\usetikzlibrary {decorations.pathmorphing}
\begin{document}

\begin{tikzpicture}[inner sep=0,outer sep=0,]

    % circles (from centre)
    \node[thick,draw=black,circle,
        minimum size=1cm,
        decorate,
        decoration={random steps,segment length=1.5pt,amplitude=0.2pt}] (centre) at (0,0) {};

    \node[thick,draw=black,circle,
        minimum size=4.5cm,
        decorate,
        decoration={random steps,segment length=1.5pt,amplitude=0.2pt}] (inedge) at (0,0) {};

    \node[thick,draw=black,circle,
        minimum size=5cm,
        decorate,
        decoration={random steps,segment length=1.5pt,amplitude=0.2pt}] (outedge) at (0,0) {};

    % main direction nodes
    \begin{scope}[label distance=0.5cm]
    % North
    \node[thick,draw=black,circle,
        minimum size=0.3cm,
        label=above:\Large{$\mathcal{N}$}] (N) at (0,3.5) {};

        \node[circle,draw=black,fill=black,
        minimum size=1.5mm] (n) at (0,3.5) {};
    % East
    \node[thick,draw=black,circle,
        minimum size=0.3cm,
        label=right:\Large{$\mathcal{E}$}] (E) at (3.5,0) {};

        \node[circle,draw=black,fill=black,
        minimum size=1.5mm] (e) at (3.5,0) {};
    % South
    \node[thick,draw=black,circle,
        minimum size=0.3cm,
        label=below:\Large{$\mathcal{S}$}] (S) at (0,-3.5) {};

        \node[circle,draw=black,fill=black,
        minimum size=1.5mm] (s) at (0,-3.5) {};
    % West
    \node[thick,draw=black,circle,
        minimum size=0.3cm,
        label=left:\Large{$\mathcal{W}$}] (W) at (-3.5,0) {};

        \node[circle,draw=black,fill=black,
        minimum size=1.5mm] (w) at (-3.5,0) {};
    \end{scope}

    % mainlines
    \draw[thick,
        decorate,
        decoration={random steps,segment length=3pt,amplitude=0.1pt}]
        (centre) -- (N);

    \draw[thick,
        decorate,
        decoration={random steps,segment length=3pt,amplitude=0.1pt}]
        (centre) -- (E);

    \draw[thick,
        decorate,
        decoration={random steps,segment length=3pt,amplitude=0.1pt}]
        (centre) -- (S);

    \draw[thick,
        decorate,
        decoration={random steps,segment length=3pt,amplitude=0.1pt}]
        (centre) -- (W);

    % Main points
    \filldraw[draw=red,fill=blue] (-0.35cm,0.35cm) -- (N.north) -- (centre.center) -- cycle; % why u no fill?!!


\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容