
我想創建一個帶有彎曲邊的填充矩形,如下圖所示:
\begin{tikzpicture}
\draw[red,thick] (0,-3) -- (0,0) -- (3,0) -- (3,-3) edge [bend left] (1,-3);
\draw[red,thick,fill] (1,-3) edge [bend right] ( 0, -3) ;
\end{tikzpicture}
我無法正確填寫。
答案1
您可以使用tikz 庫tape
中的形狀。shapes
\documentclass[tikz]{standalone}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}
\node[tape, draw]{ABCD};
\node[tape, draw, tape bend top=none,tape bend height=2mm, %% tape bend bottom=none
tape bend bottom=out and in,fill=red,minimum width=2cm,minimum height=3cm] at (2.5, 0) {};
\end{tikzpicture}
\end{document}
如果你想刻意地畫它們,你可以這樣做:
\documentclass[tikz]{standalone}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}
\draw[red,thick,fill=olive!40] (0,-3) -- (0,0) -- (3,0) -- (3,-3)
to [out=220,in=30] ( 0, -3) --cycle ;
\end{tikzpicture}
\begin{tikzpicture}
\draw[red,thick,fill=olive] (0,-3) -- (0,0) -- (3,0) -- (3,-3)
to [out=220,in=-40] (1,-3)
to [out=140,in=30] ( 0, -3) --cycle ;
\end{tikzpicture}
\end{document}
答案2
這是對 MetaPost 的嘗試,但我想它可以很容易地適應蒂克茲使用嗜好包:它利用了 MetaPost 強大的路徑規範和結構(使用 John Hobby 的演算法),嗜好包允許導入到蒂克茲。在矩形的兩個基點指定足夠的方向(作為角度)就足夠了。
使用任何引擎(LaTeX、pdfLaTeX...)進行處理外殼逃逸模式。
編輯我添加了一個蒂克茲版本,因此使用嗜好包,在這篇文章的末尾,產生相同的圖片。該代碼確實有點初級,因為我不太了解蒂克茲然而。
\documentclass{article}
\usepackage[shellescape]{gmp}
\begin{document}
\begin{mpost*}
u = 1cm; % scale
myangle = 30; % "curving" parameter, in degrees
z = (2u, 3u);
path rect; rect = origin{dir myangle} .. (x, 0){dir myangle} -- z -- (0, y) -- cycle;
fill rect withcolor red; draw rect withcolor blue;
\end{mpost*}
\end{document}
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{hobby}
\begin{document}
\begin{tikzpicture}
\draw[blue, fill=red, use Hobby shortcut] ([out angle = 30, in angle = -150]0,0) .. (2,0)
-- (2,3) -- (0,3) -- cycle ;
\end{tikzpicture}
\end{document}
答案3
我通過將兩個圓弧與一個矩形拼湊在一起來完成此操作:
\documentclass[]{article}
\usepackage{tikz}
\begin{document}
\def\x{34.0} % Angle parameter
\def\y{1.79} % Radius parameter
\begin{tikzpicture}
\fill[red,thick] (0,-3) -- (0,0) -- (3,0) -- (3,-3) -- cycle;
\filldraw[red] (3,-2.99) arc (-90+\x:-90-\x:\y);
\filldraw[white] (0,-3.01) arc (90+\x:90-\x:\y/2);
\end{tikzpicture}
\end{document}
當與原始輪廓(藍色)重疊時: