我的論文中有一張圖片,其中我正在討論基本顏色概念和指南針的相似之處。原始圖像是我在 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
並創建 a/.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}