자체 교차 선 / 곡선 장식
자체 교차하는 선이 그 위에 그려 지도록 이중선을 그리는 데 데코레이션 / 포스트 액션을 정의 할 수 있습니까? 내가 의미하는 바를 보여주기 위해 이러한 나선을 참조하십시오.
\documentclass[tikz, border=1cm]{standalone}
\begin{document}
\begin{tikzpicture}
\draw[red, double=yellow, thick, domain=0:pi, smooth, samples=200] plot (\x, {cos(10*\x r)} , {sin(10*\x r)} );
\begin{scope}[yshift=-3cm]
\foreach \i in {1,...,10}
\draw[red, double=yellow, thick, domain=pi*(\i-1)/10:pi*\i/10, smooth, samples=200] plot (\x, {cos(10*\x r)} , {sin(10*\x r)} );
\end{scope}
\end{tikzpicture}
\end{document}

상단 완화 곡선은 일반 이중선의 효과를 나타내고 하단 완화 곡선은 원하는 결과를 보여줍니다. \draw
인공물 렌더링을 방지하고 smooth
옵션이 전체 나선형에서 작동 하도록하기 위해 단 하나의 명령으로 결과가 완료되기를 바랍니다 .
궁극적으로 나는 흰색을 바깥쪽으로 사용하여 교차 효과를 만들 수 있기를 원합니다. 이 사이트의 질문에 더 잘 대답 할 수 있도록하기 위해 (예 : 원추형 및 원통형 나선형)
그리면서 경로의 작은 부분에 이중을 만들어서 가능해야한다고 생각했습니다. 다음과 같은 순진한 접근 방식 :
\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary {decorations.pathmorphing}
\begin{document}
\begin{tikzpicture}
\draw[yellow,
decorate, decoration={zigzag, segment length=1mm, amplitude=0mm},
preaction={draw, ultra thick, red},
domain=0:pi, samples=200] plot (\x, {cos(10*\x r)} , {sin(10*\x r)} );
\end{tikzpicture}
\end{document}
사전 작업이 세그먼트가 아닌 전체 경로에 적용되므로 작동하지 않습니다.
더 나은 해결책은 경로 clip
자체가 가능하여 흰색이 아닌 배경에서 교차점이 멋지게 보이도록하는 것입니다. -아마도 꽤 복잡 할 것입니다.
답변
다음은 show path construction
.
\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}[path decomposition/.style={%
postaction={decoration={show path construction,
lineto code={
\draw[#1] (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast);
},
curveto code={
\draw[#1] (\tikzinputsegmentfirst) .. controls
(\tikzinputsegmentsupporta) and (\tikzinputsegmentsupportb)
..(\tikzinputsegmentlast) ;
},
closepath code={
\draw[#1] (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast) {closepath};} }
,decorate}}]
\draw[red, double=yellow, thick, domain=0:pi, smooth, samples=200,
path decomposition={red, double=yellow, thick}] plot (\x, {cos(10*\x r)} , {sin(10*\x r)} );
\begin{scope}[yshift=-3cm]
\foreach \i in {1,...,10}
\draw[red, double=yellow, thick, domain=pi*(\i-1)/10:pi*\i/10, smooth, samples=200] plot (\x, {cos(10*\x r)} , {sin(10*\x r)} );
\end{scope}
\end{tikzpicture}
\end{document}

이 답변 에는 이미 완전한 스타일 이 있습니다.
knotsTikZ 라이브러리는 이런 종류의 물건을 처리합니다. plot
그리기 명령 을 사용하면 매우 짧은 선 이 많이 생성 knots
되고 하위 경로 사이의 교차점을 찾기 때문에 작동 방식에 좋지 않기 때문에 약간의 문제가 있습니다. 다행히도 hobby라이브러리를 사용하면 베 지어 곡선을 사용하여 보간하므로 샘플 수를 상당히 줄일 수 있습니다.
knots
교차점에서 곡선의 한 부분을 다시 그리는하여 라이브러리의 작품은 육교 효과를합니다.
knots
라이브러리 와 함께 이중 옵션을 사용하면 PDF를 볼 때 인공물을 생성 할 수 있습니다 (인쇄 할 때는 아님). 그것들을 제거하는 방법 은 tikz knot 라이브러리의 "crop circle"문제에 자세히 설명되어 있습니다.
코드는 다음과 같습니다.
\documentclass{article}
%\url{https://tex.stackexchange.com/q/572737/86}
\usepackage{tikz}
\usetikzlibrary{knots,hobby}
\tikzset{
basic strand/.style={
red,
double=yellow,
double distance=1pt,
},
crossing strand/.style={
line width=1.8pt,
only when rendering/.style={%
draw=yellow,%
line width=1pt,
double=none,
}
}
}
\begin{document}
\begin{tikzpicture}[use Hobby shortcut]
\begin{knot}[
consider self intersections=true,
ignore endpoint intersections=false,
background colour=red,
every intersection/.style={
crossing strand
},
only when rendering/.style={
basic strand
},
clip width=1
]
\strand (0,1,0) \foreach \x in {1,...,80} { .. (\x/80*pi, {cos(22.5*\x )} , {sin(22.5*\x )} ) };
\end{knot}
\end{tikzpicture}
\end{document}
결과:
