Tikz 노드를 곡선으로 만드는 방법은 무엇입니까?

Tikz 노드를 곡선으로 만드는 방법은 무엇입니까?

이것은 매우 간단한 질문입니다.

노드에 "곡선" 효과를 추가할 수 있습니까?

간단한 직사각형 노드를 고려해보세요:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node[draw,minimum width=3cm,minimum height=2cm]{};
\end{tikzpicture}
\end{document}

다음 이미지처럼 곡선을 만들고 싶습니다.

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

이는 모든 노드 모양에 적용 가능해야 합니다.

답변1

이는 를 통한 가능한 솔루션 중 하나입니다 tikz pics. 여기서 marco라는 이름은 mynode서로 다른 x, y 길이와 곡률을 갖춘 6개의 인수로 정의됩니다. 마지막은 곡선이 있는 텍스트 레이블용입니다. 텍스트가 전혀 없으면 코드에서 경로 장식을 제거합니다.

삼각형과 같은 다른 모양에도 동일한 아이디어를 적용할 수 있지만 코드를 약간 수정해야 할 수도 있습니다. 다음은 인수의 정의입니다.

#1=color, #2=x length, #3=y height, #4=inward bend angle, #5=outward bend angle, #6=text

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

암호

\documentclass[border=10pt]{standalone}%{article}
\usepackage{tikz}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{decorations.text}
\tikzset{%
pics/.cd,
mynode/.style args={#1#2#3#4#5#6}{
code={\node[inner sep=0pt,outer sep=0pt] at (0,0) (a) {};
\path[fill=#1] 
(a) to[bend right=#4] ++(#2,0) -- ++(0,#3) to[bend left=#5] ++(-#2,0) -- cycle;
\path[postaction={decorate},           % remove this path if no text decoration.
         decoration={raise=-15pt,
         text along path, text={#6},
         text align={left indent ={1cm}}}] 
(a) to[bend right=#4] ++(#2,0); 
}},
}

% #1=color, #2=x length, #3=y height, #4= inward bend  angle, #5= outward bend angle, #6=text

\begin{document}
\begin{tikzpicture}
  \pic {mynode={purple}{6cm}{-1cm}{20}{10}{This is my curved text.}};
  \pic at (0,-2) {mynode={olive}{6cm}{-2cm}{30}{20}{This is my curved text.}};
  \pic at (0,-5) {mynode={blue}{6cm}{-2cm}{40}{30}{This is my curved text.}};
\end{tikzpicture}
\end{document}

관련 정보