我正在尝试通过用椭圆裁剪外部图像来创建精美图像 - 仅显示椭圆内部的区域。我见过这,但我仍然需要帮助。有人可以帮忙吗?
以下是我所说的一个例子:
答案1
使用 PSTricks 只是为了好玩。
\documentclass[pstricks,border=12pt]{standalone}
\usepackage{graphicx}
\newsavebox\IBox
\savebox\IBox{\includegraphics[scale=1]{example-grid-100x100pt}}
\psset
{
xunit=.1\wd\IBox,
yunit=.1\ht\IBox,
}
\begin{document}
\begin{pspicture}(10,10)
\psclip{\psellipse(5,5)(5,4)}
\rput(5,5){\usebox\IBox}
\endpsclip
\end{pspicture}
\end{document}
奖金
椭圆形的蝙蝠侠剪切路径。
\documentclass[pstricks,border=0pt]{standalone}
\SpecialCoor
\usepackage{graphicx}
\newsavebox\IBox
\savebox\IBox{\includegraphics[scale=1]{example-grid-100x100pt}}
\psset
{
xunit=\dimexpr\wd\IBox/14,
yunit=\dimexpr\ht\IBox/14,
}
% b a t p2c ---> x y
% where b (semi-minor), a (semi-major), t (theta)
\pstVerb{/p2c {dup 3 1 roll cos mul 3 1 roll sin mul} bind def}
\def\RightPart
{
\psline(0.5,2.7)(1,3.25)
\psbezier(1.2,1.3)(1.3,1.0)(2.0,1.0)
\psbezier(3.0,1.0)(3.0,2.2)(!3.3 6.0 72 p2c)
\psellipticarcn(6.0,3.3){(!3.3 6.0 72 p2c)}{(!3.3 6.0 72 neg p2c)}
\psbezier(4,-2)(4,0)(2.2,-1.8)
\psbezier(1.5,-1)(1,-1)(0,-3.2)
}
\begin{document}
\begin{pspicture}(-7,-4)(7,4)
\psclip{
\pscustom[dimen=monkey]
{
\RightPart
\reversepath
\scale{-1 1}
\RightPart
\closepath
}}
\rput(0,0){\usebox\IBox}
\endpsclip
\end{pspicture}
\end{document}
答案2
使用 TikZ
代码
\documentclass[border=2pt]{standalone}
\usepackage{tikz}
\usepackage{mwe} % provides example-image-a
\begin{document}
\begin{tikzpicture}
\clip(0,0)circle[x radius=4cm, y radius=2cm];
\node{\includegraphics{example-image-a}};
\end{tikzpicture}
\end{document}