这可能看起来重复,但我正尝试根据下图为邀请卡绘制一个特定的凹凸装饰矩形:
因此,我一直在使用 tikz 的装饰库,但无论我为圆角、振幅和段设置什么值,我都无法按照我想要的方式匹配装饰矩形的角。结果看起来更像一朵云,而不是我期望的那样。
以下是 MWE:
\documentclass[10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{calligra}
\usepackage[paperwidth=15cm, paperheight=10cm, top=1cm, left=1cm, right=1cm, bottom=1cm]{geometry}
\usepackage{tikz}
%\usetikzlibrary{decorations}
\usetikzlibrary{decorations.pathmorphing, positioning}
\begin{document}
\thispagestyle{empty}
\begin{tikzpicture}[remember picture, overlay]
%Outside corners
\node[anchor=45,below=0.5cm, xshift=1.5cm] (SD) at (current page.45) {};
\node[anchor=135,below=0.5cm,xshift=-1.5cm] (SI)at (current page.135) {};
\node[anchor=225,above=0.5cm,xshift=-1.5cm] (II)at (current page.225) {};
\node[anchor=315,above=0.5cm,xshift=1.5cm] (ID)at (current page.315) {};
%Inside corners
\node[] (RSD) [below=10pt, left of=SD, xshift=20pt] {};
\node[] (RSI) [below right of= SI] {};
\node[] (RII) [above right of= II] {};
\node[] (RID) [above left of =ID] {};
\draw[thick, rounded corners=7mm, decorate, decoration={bumps, segment length=7mm, amplitude=5}] (SD) rectangle (II) [sharp corners] {};
%--(ID)--(II)--(SI)} {};
\draw[thick] (RSD) rectangle (RII) {};
\end{tikzpicture}
我做错了什么?提前致谢!
Ch。
答案1
相反,decorations
你可以一直绘制框架by hand
,这意味着:
- 绘制并填充具有外部尺寸的矩形
- 绘制并填充所需数量的圆圈
- 绘制并填充内部矩形
- 填写你的邀请卡
以下代码显示了我的解决方案。它使用standalone
包,并且卡片尺寸用坐标固定,tikzpicture
而不是使用geometry
包。我认为这种方式更简单。
\documentclass[tikz, 10pt, margin=2mm]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{calligra}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\coordinate (SD) at (-6,5);
\coordinate (SI) at (6,5);
\coordinate (ID) at (-6,-5);
\coordinate (II) at (6,-5);
\coordinate[below right = 5mm of SD] (RSD);
\coordinate[below left = 5mm of SI] (RSI);
\coordinate[above right = 5mm of ID] (RID);
\coordinate[above left = 5mm of II] (RII);
\fill[red] (SD) rectangle (II);
\foreach \i in {0,2,...,60}{
\fill[red] ([xshift=\i*2mm]SD) circle (2mm);
\fill[red] ([xshift=\i*2mm]ID) circle (2mm);
}
\foreach \i in {0,2,...,50}{
\fill[red] ([yshift=-\i*2mm]SD) circle (2mm);
\fill[red] ([yshift=-\i*2mm]SI) circle (2mm);
}
\fill[black!10] (RSD) rectangle (RII);
\node[font=\Huge\calligra] {Happy birthday!};
\end{tikzpicture}
\end{document}