![如何在 tikz 中绘制右上角修剪的矩形?](https://linux22.com/image/465218/%E5%A6%82%E4%BD%95%E5%9C%A8%20tikz%20%E4%B8%AD%E7%BB%98%E5%88%B6%E5%8F%B3%E4%B8%8A%E8%A7%92%E4%BF%AE%E5%89%AA%E7%9A%84%E7%9F%A9%E5%BD%A2%EF%BC%9F.png)
如果可能的话,我想code
在 tikz 中绘制一个图形(看起来像矩形,但右上角被修剪)。基本示例如下:
____
| \
|< >|
|___|
有这个的样本吗?
原图取自:https://git-lfs.com
答案1
像这样吗?
\documentclass[10pt,border=3mm,tikz]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[line width=3pt]
\draw (2.3,6.5) -- (-4.3,6.5) -- (-4.3,-6.6) -- (4.3,-6.6) -- (4.3,3.7) -- cycle;
\draw (-.9,1.6) -- (-2.9,0) -- (-.9,-1.6);
\draw (.9,1.6) -- (2.9,0) -- (.9,-1.6);
\end{tikzpicture}
\end{document}
也可以尝试这些:
\draw (1.5,3.25) -- (-2.65,3.25) -- (-2.65,-3.3) -- (2.85,-3.35) -- (2.85,1.85) -- cycle;
\draw (-.45,.8) -- (-1.45,-.25) -- (-.55,-1.3);
\draw ( .45,.8) -- ( 1.45,-.25) -- ( .55,-1.3);
答案2
还有chamfered rectangle
节点形状:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.misc}
\tikzset{fileshape/.style 2 args={chamfered rectangle,
draw, ultra thick,
chamfered rectangle corners=north east,
minimum height=12mm, minimum width=10mm,
#1, label={[text=#1]270:{\sffamily #2}}
}}
\begin{document}
\begin{tikzpicture}
\node[fileshape={gray}{code}]at (0,0) (A){$<>$};
\node[fileshape={cyan}{file.psd}]at (2,0) (B){};
\draw[thick, gray] (A)--(B);
\end{tikzpicture}
\end{document}
答案3
这是绘制两个图标的方法。
最初的想法是按照图式人物的曲线走。但事实证明,这并不必要,你也可以在正确的位置放一个圆圈,只要路径是封闭的。
正如一条评论内的链接所指出的那样,使用带有切角的极坐标可能会很有用。
而且比例相当大。最好的方法是使用计算器(或 tikzlib )来调整坐标,calc
而不是使用scale
(详情请参阅手册)。
\documentclass[10pt,border=3mm,tikz]{standalone}
\usepackage{tikz}
\begin{document}
% ~~~ pictures ~~~~~~~~~
\tikzset{
symb/.pic={
\draw (1.5,3.25) -- (-2.65,3.25) -- (-2.65,-3.3) -- (2.85,-3.35) -- (2.85,1.85) -- cycle;
\draw (-.45,.8) -- (-1.45,-.25) -- (-.55,-1.3);
\draw ( .45,.8) -- ( 1.45,-.25) -- ( .55,-1.3);
}
}
\tikzset{
pers/.pic={
\draw (1.5,3.25) -- (-2.65,3.25) -- (-2.65,-3.3) -- (2.85,-3.35) -- (2.85,1.85) -- cycle;
\draw [fill=black] (1.05,1.95) -- (-1.95,2) -- (-1.95,-2) --
(-0.95, -2) arc [start angle=180,end angle=90,radius=1cm] --
++(0,0) arc [start angle=270,end angle=-90,radius=1cm] --
++ (0,0) arc [start angle=90,end angle=0,radius=1cm]
-- (2.05,-2) -- (2.05,1) -- cycle;
}
}
% ~~~ demo ~~~~~~~~~~~~~~~~
\begin{tikzpicture}[line width=3pt]
\pic at (0,0) {symb};
\pic at (6,0) {pers};
\pic at (12,-9) {pers};
\end{tikzpicture}
\end{document}
附言:当您向圆圈添加白色轮廓时,就会发生这种情况pers
:
---
\draw [fill=black,draw=white] (1.05,1.95) -- (-1.95,2) ...