我想在 TikZ 中使用 shapes.geometric 生成一个多边形,然后水平拉伸它,但只拉伸多边形的一部分。具体来说,我想使用由
\node[draw,minimum size=2cm,regular polygon,regular polygon sides=6] (H) {};
但对其进行修改,使多边形的顶部和底部水平边水平拉伸,而其他四条边保持其原始长度,并且仍然(H.corner 2)
引用修改后的六边形中角的坐标。
答案1
这款附赠一只免费海鸥(do you see it ?)
!
输出
代码
\documentclass[12pt,tikz]{standalone}
\begin{document}
\begin{tikzpicture}
[
seagull/.pic=
{
\draw (-3mm,0) to [bend left] (0,0) to [bend left] (3mm,0);
},
pics/myHexagon/.style args={#1/#2}%
{
code=
{
\pgfmathsetmacro{\mySqrt}{sqrt(3)/2}
\def\r{#1}
\def\a{#2}
\draw [cm={\r,0,.5*\r,\mySqrt*\r,(0,0)}]
(1+\a,0) coordinate (-corner 0) coordinate (-corner 6)
-- (\a,1) coordinate (-corner 1)
-- (-1-\a,1) coordinate (-corner 2)
-- (-1-\a,0) coordinate (-corner 3)
-- (-\a,-1) coordinate (-corner 4)
-- (1+\a,-1) coordinate (-corner 5)
-- cycle;
}
}
]
\pic at (0,0) {seagull};
\pic (monHexa) {myHexagon={2/.2}};
\foreach \k in {0,...,6}
{
\node at (monHexa-corner \k) {corner \k};
}
\end{tikzpicture}
\end{document}