答案1
我会给你我的意见,以防万一。
1. 使用 shapes.misc 库
\begin{tikzpicture}
\node[
draw,
rounded corners=3pt,
minimum width=3cm,
minimum height=2cm,
rounded rectangle,
rounded rectangle left arc=none,
font=\sffamily\Large] {Hello};
\end{tikzpicture}
2. 使用图片并手动插入锚点
\begin{tikzpicture}
\tikzset%
{
pin/.style={Circle[]-,red},
rectell/.pic={
\draw (0,0.5*3) coordinate(-north) -| (-0.5*5,0) coordinate(-west) |- (0,-0.5*3) coordinate(-south) arc(-90:0:0.5*5 cm and 0.5*3 cm) coordinate(-east) arc(0:90:0.5*5 cm and 0.5*3 cm) -- cycle;
\node (-center) at (0,0) {#1};
}
}
\draw (0,0) pic(A){rectell={\sffamily\Huge Hello}};
\draw[pin] (A-center.center) --++ (3,3) node[above] {A-center};
\draw[pin] (A-north) --++ (-1,1) node[above] {A-north};
\draw[pin] (A-west) --++ (-1,1) node[above] {A-west};
\draw[pin] (A-south) --++ (-1,-1) node[below] {A-south};
\draw[pin] (A-east) --++ (1,1) node[above] {A-east};
\end{tikzpicture}
完整代码(带序言):
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,shapes.misc}
\begin{document}
\begin{tikzpicture}
\node[
draw,
rounded corners=3pt,
minimum width=3cm,
minimum height=2cm,
rounded rectangle,
rounded rectangle left arc=none,
font=\sffamily\Large] {Hello};
\end{tikzpicture}
\bigskip
\begin{tikzpicture}
\tikzset%
{
pin/.style={Circle[]-,red},
rectell/.pic={
\draw (0,0.5*3) coordinate(-north) -| (-0.5*5,0) coordinate(-west) |- (0,-0.5*3) coordinate(-south) arc(-90:0:0.5*5 cm and 0.5*3 cm) coordinate(-east) arc(0:90:0.5*5 cm and 0.5*3 cm) -- cycle;
\node (-center) at (0,0) {#1};
}
}
\draw (0,0) pic(A){rectell={\sffamily\Huge Hello}};
\draw[pin] (A-center.center) --++ (3,3) node[above] {A-center};
\draw[pin] (A-north) --++ (-1,1) node[above] {A-north};
\draw[pin] (A-west) --++ (-1,1) node[above] {A-west};
\draw[pin] (A-south) --++ (-1,-1) node[below] {A-south};
\draw[pin] (A-east) --++ (1,1) node[above] {A-east};
\end{tikzpicture}
\end{document}
编辑:使用的参数图片作为节点
如果你想画一幅画节点并选择宽度和高度,您可以在调用时将这些参数作为参数传递给图片。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}
\tikzset%
{
pin/.style={Circle[]-,red},
%
pics/rectell/.style args={#1/#2/#3}{code = {
\draw (0,0.5*#3) coordinate(-north) -| (-0.5*#2,0) coordinate(-west) |- (0,-0.5*#3) coordinate(-south) arc(-90:0:0.5*#2 cm and 0.5*#3 cm) coordinate(-east) arc(0:90:0.5*#2 cm and 0.5*#3 cm) -- cycle;
\coordinate (-center) at (0,0) node {#1};
}}
}
\draw (0,0) pic(A){rectell={\sffamily\Huge Width 7 Height 3}/7/3};
\draw[pin] (A-center) --++ (3,2) node[above] {A-center};
\draw[pin] (A-north) --++ (-1,1) node[above] {A-north};
\draw[pin] (A-west) --++ (-1,1) node[above] {A-west};
\draw[pin] (A-south) --++ (-1,-1) node[below] {A-south};
\draw[pin] (A-east) --++ (1,1) node[above] {A-east};
\draw (0,-6) pic{rectell={\sffamily\Huge W 4 H 5}/4/5};
\end{tikzpicture}
\end{document}