TikZ를 사용하여 이와 같은 모양을 그리는 방법은 무엇입니까?
답변1
부분102.5.3 새로운 도형 선언 명령pgf 매뉴얼에는 document
요청한 것과 유사한 모양을 선언하는 예제가 포함되어 있습니다. 이 모양에 를 추가하면 double copy shadow
원하는 결과를 얻을 수 있습니다.
코드(필요에 따라 설정 조정):
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shadows}
\makeatletter
\pgfdeclareshape{document}{
\inheritsavedanchors[from=rectangle] % this is nearly a rectangle
\inheritanchorborder[from=rectangle]
\inheritanchor[from=rectangle]{center}
\inheritanchor[from=rectangle]{north}
\inheritanchor[from=rectangle]{south}
\inheritanchor[from=rectangle]{west}
\inheritanchor[from=rectangle]{east}
% ... and possibly more
\backgroundpath{% this is new
% store lower right in xa/ya and upper right in xb/yb
\southwest \pgf@xa=\pgf@x \pgf@ya=\pgf@y
\northeast \pgf@xb=\pgf@x \pgf@yb=\pgf@y
% compute corner of ‘‘flipped page’’
\pgf@xc=\pgf@xb \advance\pgf@xc by-7.5pt % this should be a parameter
\pgf@yc=\pgf@yb \advance\pgf@yc by-7.5pt
% construct main path
\pgfpathmoveto{\pgfpoint{\pgf@xa}{\pgf@ya}}
\pgfpathlineto{\pgfpoint{\pgf@xa}{\pgf@yb}}
\pgfpathlineto{\pgfpoint{\pgf@xc}{\pgf@yb}}
\pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@yc}}
\pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@ya}}
\pgfpathclose
% add little corner
\pgfpathmoveto{\pgfpoint{\pgf@xc}{\pgf@yb}}
\pgfpathlineto{\pgfpoint{\pgf@xc}{\pgf@yc}}
\pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@yc}}
\pgfpathlineto{\pgfpoint{\pgf@xc}{\pgf@yc}}
}
}
\makeatother
\begin{document}
\begin{tikzpicture}
\node[
shape=document,
double copy shadow={
shadow xshift=-0.5ex,
shadow yshift=-0.5ex
},
draw,
fill=white,
line width=1pt,
text width=1cm,
minimum height=1.7cm
] {};
\end{tikzpicture}
\end{document}
여러 번 사용하려면 스타일을 정의하여 코드를 단순화할 수 있습니다.
답변2
여기에 한 가지 해결책이 있습니다. 여러 번 재사용하고 싶다면 pic
.
\usetikzlibrary{shadings}
\usetikzlibrary{shadows}
\begin{tikzpicture}
\foreach \i in {1,2,3} {
\begin{scope}[shift={(.2*\i,.2*\i)}]
\draw[bottom color=black!7, top color=white, drop shadow={shadow xshift=-.4ex}]
(0,0) -- ++(3,0) -- ++(0,3) -- ++(-1,1) -- ++(-2,0) -- cycle;
\draw (3,3) -| (2,4);
\end{scope}
}
\end{tikzpicture}