TikZ에서 각 가장자리를 개별적으로 색칠합니다.

TikZ에서 각 가장자리를 개별적으로 색칠합니다.

가장자리 AB를 두꺼운 파란색으로, 가장자리 AC와 BC를 두꺼운 빨간색으로 색칠하고 싶습니다.

의 답변을 참고하여TikZ의 여러 색상 가장자리, 한 가지 방법은 명령을 사용하는 것입니다 \clip[draw]. 하지만 내 모양이 삼각형이고 삼각형도 주황색으로 채워져 있기 때문에 내 상황에서 어떻게 사용하는지 잘 모르겠습니다.

예상 결과:

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

현재 결과:

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

삼각형은 여전히 ​​주황색으로 채워져 있어야 하며 가장자리는 위에서 언급한 색상이어야 합니다.

메모: 이 예는 PGF 매뉴얼에서만 나온 것입니다. 설명 없이 매뉴얼에 코드를 제공하는 것은 권장/감사되지 않습니다.

\filldraw또는 \draw[fill]명령을 사용하는 대신 도형을 채우는 다른 방법이 있습니까 ?

MWE:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{through}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}[help lines/.style={thin,draw=black!50}]
  \coordinate[label=left:\textcolor{blue!80!black}{$A$}] (A) at (0,0);
  \coordinate[label=right:\textcolor{blue!80!black}{$B$}] (B) at (1.25,0.25);
  \draw[name path=A--B] (A) -- (B);
%  \draw let \p1 = ($(B) - (A)$),
%            \n2 = {veclen(\x1,\y1)}
%        in
%           (A) circle (\n2)
%           (B) circle (\n2);
  \node (D) [name path=D,draw,circle through=(B),label=left:$D$,help lines,draw] at (A) {};
  \node (E) [name path=E,draw,circle through=(A),label=right:$E$,help lines,draw] at (B) {};

  \path [name intersections={of=D and E, by={[label=above:$C$]C,[label=below:$C'$]C'}}];

  %\coordinate[label=above:$C$] (C) at (intersection-1); using by instead

  \draw [name path=C--C',red] (C) -- (C');

  \path [name intersections={of=A--B and C--C', by=F}];
  \node[fill=red,inner sep=1pt, label=-45:$F$] at (F) {};

  \draw[fill=orange!80] (A) -- (B) -- (C) -- cycle;
  \foreach \point in {A,B,C}
    \fill [black,opacity=0.5] (\point) circle (2pt);
\end{tikzpicture}
\end{document} 

답변1

일부 옵션은 다음에 적용될 수 있습니다.경로의 일부, 의 경우입니다 rounded corners. 그러나 이것은 colors항상 적용되는 매뉴얼 3.1.1의 149페이지에 표시된 대로 작동하지 않습니다.전체 경로.

149페이지의 스크린샷:

스크린샷

따라서 더 쉽게 만들려면 다음을 수행하십시오.

  • \fill먼저 명령 으로 ABC 삼각형을 주황색으로 채색했습니다.(아무것도 그리지 않습니다);
  • 그럼 내가 그렸어경로 중 하나는 에 있고 blue다른 하나는 에 있습니다 red.

스크린샷

주석 처리된 코드:

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{through}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}[help lines/.style={thin,draw=black!50}]
  \coordinate[label=left:\textcolor{blue!80!black}{$A$}] (A) at (0,0);
  \coordinate[label=right:\textcolor{blue!80!black}{$B$}] (B) at (1.25,0.25);
  \path[name path=A--B] (A) -- (B);% <-- construct the path, but not draw it
%  \draw let \p1 = ($(B) - (A)$),
%            \n2 = {veclen(\x1,\y1)}
%        in
%           (A) circle (\n2)
%           (B) circle (\n2);
  \node (D) [name path=D,draw,circle through=(B),label=left:$D$,help lines,draw] at (A) {};
  \node (E) [name path=E,draw,circle through=(A),label=right:$E$,help lines,draw] at (B) {};

  \path [name intersections={of=D and E, by={[label=above:$C$]C,[label=below:$C'$]C'}}];

  %\coordinate[label=above:$C$] (C) at (intersection-1); using by instead

  \path [name path=C--C',red] (C) -- (C');

  \path [name intersections={of=A--B and C--C', by=F}];
  %\node[fill=red,inner sep=1pt, label=-45:$F$] at (F) {};

  \fill[orange!80] (A) -- (B) -- (C) -- cycle;%<-- only fill without draw the edges
  \draw[blue,thick](A)--(B);%<-- draw in blue
  \draw[red,thick](A)--(C)--(B);%<-- draw in red
  \foreach \point in {A,B,C}
    \fill [black,opacity=0.5] (\point) circle (2pt);
\end{tikzpicture}
\end{document} 

답변2

\path또는 명령 을 사용하여 일부 경로를 저장할 수 있습니다 \draw. 특히 교차점을 해당 경로에 통합하여 빈 경로를 제거할 수 있습니다.

A두 점 사이에 선을 그리는 방법 으로 색상을 지정하려면 B(프레임을 그린 후 또는 단순히 프레임을 제거한 후) 에서도 마찬가지입니다 A--B--C.

삼각형

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{through}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}[help lines/.style={thin,draw=black!50}]
  \path[name path=A--B] (0,0) coordinate[label=left:\textcolor{blue!80!black}{$A$}] (A) --
    (1.25,0.25) coordinate[label=right:\textcolor{blue!80!black}{$B$}] (B);
  \node (D) [name path=D,draw,circle through=(B),label=left:$D$,help lines,draw] at (A) {};
  \node (E) [name path=E,draw,circle through=(A),label=right:$E$,help lines,draw] at (B) {};
  \draw[name intersections={of=D and E, by={[label=above:$C$]C,[label=below:$C'$]C'}},
    name path=C--C',red] (C) -- (C');
  \node[fill=red,inner sep=1pt,name intersections={of=A--B and C--C', by=F},label=-45:$F$] at (F) {};

  \draw[draw=none,fill=orange!80] (A) -- (B) -- (C) -- cycle;
  \draw[blue,thick] (A) -- (B);
  \draw[red,thick] (A) -- (C) -- (B);

  \foreach \point in {A,B,C}
    \fill [black,opacity=0.5] (\point) circle (2pt);
\end{tikzpicture}
\end{document} 

관련 정보