
를 사용하여 사용자 정의 모양을 구성했으며 pdfdeclareshape
다음 다이어그램에서 사용하고 있습니다.
이상적으로는 텍스트와 별도로 테두리를 회전하여 결국 이미지와 비슷하게 보이도록 하고 싶습니다.이 질문.
공부한 결과pgf
매뉴얼과Tikz에서 노드와 텍스트를 독립적으로 회전하는 방법(예를 들어) 사용을 목표로 해야 한다고 생각 shape border rotate
하지만, 모든 도형이 기본적으로 지원하는 것은 아닙니다.
내 사용자 정의 모양의 테두리를 텍스트와 별도로 회전할 수 있나요? (내 사용자 정의 모양이 개선될 수 있다면 자유롭게 비판해 주세요.)
% arara: pdflatex
\documentclass[tikz]{standalone}
\makeatletter
\pgfdeclareshape{petal}
{
\inheritsavedanchors[from=circle] % this is nearly a circle
\inheritanchorborder[from=circle]
\inheritanchor[from=circle]{center}
\inheritanchor[from=circle]{base}
\backgroundpath{
% origin
\centerpoint%
\pgf@xc=\pgf@x%
\pgf@yc=\pgf@y%
\pgfutil@tempdima=\radius%
\pgfpathmoveto{\pgfpointadd%
{\pgfqpoint{\pgf@xc}{\pgf@yc}}
{\pgfqpoint{-\pgfutil@tempdima}{0\pgfutil@tempdima}}}
\pgfpatharc{180}{0}{\pgfutil@tempdima}
\pgfpathcurveto{%
\pgfpointadd{\pgfqpoint{\pgf@xc}{\pgf@yc}}{\pgfqpoint{0.9\pgfutil@tempdima}{-.9\pgfutil@tempdima}}}
{\pgfpointadd{\pgfqpoint{\pgf@xc}{\pgf@yc}}{\pgfqpoint{0.5\pgfutil@tempdima}{-.5\pgfutil@tempdima}}}
{\pgfpointadd{\pgfqpoint{\pgf@xc}{\pgf@yc}}{\pgfqpoint{0\pgfutil@tempdima}{-1.5\pgfutil@tempdima}}}
\pgfpathcurveto{%
\pgfpointadd{\pgfqpoint{\pgf@xc}{\pgf@yc}}{\pgfqpoint{0\pgfutil@tempdima}{-1.5\pgfutil@tempdima}}}
{\pgfpointadd{\pgfqpoint{\pgf@xc}{\pgf@yc}}{\pgfqpoint{-0.8\pgfutil@tempdima}{-.8\pgfutil@tempdima}}}
{\pgfpointadd{\pgfqpoint{\pgf@xc}{\pgf@yc}}{\pgfqpoint{-\pgfutil@tempdima}{0\pgfutil@tempdima}}}
}
}
\makeatother
\begin{document}
\begin{tikzpicture}
\foreach \i in {1,2,...,5}
{
\pgfmathparse{90-(\i-1)*360/5}
\node[draw=black,anchor=base,rotate=-(\i-1)*360/5,petal,minimum width=1.5cm] at (\pgfmathresult:1.2cm) {\i};
}
\end{tikzpicture}
\end{document}
답변1
일부 모양에 존재하는 을 사용할 수 있습니다 shape border rotate
(또는 고유한 특수 petal rotate
키를 정의할 수 있습니다). 그러나 새로운 모양을 정의할 때는 모든 작업을 직접 수행해야 합니다. 모양 테두리를 그리는 것은 간단하지만 이 키의 값을 반영하도록 앵커를 수동으로 정의해야 할 수도 있습니다(여기에서는 수행되지 않음).
\documentclass[tikz]{standalone}
\makeatletter
\pgfkeys{/pgf/shape border rotate/.initial=0}
\pgfdeclareshape{petal}
{
\inheritsavedanchors[from=circle] % this is nearly a circle
\inheritanchorborder[from=circle]
\inheritanchor[from=circle]{center}
\inheritanchor[from=circle]{base}
\savedmacro\petalparameters{%
\pgfmathsetmacro\shapeborderrotate{\pgfkeysvalueof{/pgf/shape border rotate}}%
\addtosavedmacro\shapeborderrotate%
}
\backgroundpath{
% origin
\petalparameters%
{% Make sure transformations are inside group.
\pgftransformshift{\centerpoint}%
\pgftransformrotate{\shapeborderrotate}%
\pgfutil@tempdima=\radius%
\pgfpathmoveto{\pgfqpoint{\pgfutil@tempdima}{0pt}}%
\pgfpatharc{0}{180}{\pgfutil@tempdima}%
\pgfpathcurveto{\pgfqpoint{-\pgfutil@tempdima}{-.5\pgfutil@tempdima}}%
{\pgfqpoint{-.5\pgfutil@tempdima}{-.75\pgfutil@tempdima}}%
{\pgfqpoint{0pt}{-1.5\pgfutil@tempdima}}
\pgfpathcurveto{\pgfqpoint{0pt}{-.75\pgfutil@tempdima}}%
{\pgfqpoint{\pgfutil@tempdima}{-.75\pgfutil@tempdima}}%
{\pgfqpoint{\pgfutil@tempdima}{0pt}}%
}%
}
}
\makeatother
\begin{document}
\begin{tikzpicture}
\foreach \i in {1,2,...,5}
{
\pgfmathparse{90-(\i-1)*360/5}
\node[draw=black,anchor=base,shape border rotate=-(\i-1)*360/5,petal,minimum width=1.5cm] at (\pgfmathresult:1.25cm) {\i};
}
\end{tikzpicture}
\end{document}
답변2
PSTricks와 함께.
\documentclass[pstricks,border=12pt]{standalone}
\usepackage{multido}
\psset{linejoin=1}
\SpecialCoor
\def\atom#1%
{
\psccurve(0,0)(.3,.5)(1,1)(1,1.5)(0,2)(-1,1.5)(-1,1)
\rput{*0}(0,1){#1}
}
\begin{document}
\begin{pspicture}[showgrid=false](-3,-3)(3,3)
\multido{\ia=90+-72,\ib=0+-72,\in=1+1}{5}{\rput(.5;\ia){\rput{\ib}(0,0){\atom{\in}}}}
\end{pspicture}
\end{document}