诺曼窗看起来像一个矩形上的半圆形;例如,
如果想要拍摄现有的矩形图像并进行裁剪,以便剪切出的内容类似于诺曼窗户的周长。
考虑一下我用来编译的代码Xelatex
---
\documentclass[border=12pt]{standalone}
\usepackage{pstricks}
\usepackage{graphicx}
% Compiles with xelatex
\def\M{3}% columns
\def\N{3}% rows
\def\scale{1}% scale
\newsavebox\IBox
\savebox\IBox{\includegraphics[width=16em,height=20em]{example-image}}
\psset
{
xunit=0.5\dimexpr\wd\IBox/\M\relax,
yunit=0.5\dimexpr\ht\IBox/\N\relax,
}
\begin{document}
\begin{pspicture}[showgrid=true](-\M,-\N)(\M,\N)
\rput(0,0){\usebox\IBox}
\end{pspicture}
\end{document}
产生
问题:如果可能的话,我怎样才能精确地(不是“手工”)裁剪这幅图像,使其变成诺曼窗矩形的底边(从左边)始于点 (x,y) = (-2,-1.5);且所述矩形的尺寸为 x = 4 和 y = 2.5?
答案1
这使用了 TikZ。我认为这些数字只是为了展示。
\documentclass[border=12pt]{standalone}
\usepackage{tikz}
\usepackage{graphicx}
% Compiles with xelatex
\newsavebox\IBox
\savebox\IBox{\includegraphics[width=16em,height=20em]{example-image}}
\begin{document}
\begin{tikzpicture}
\clip (0,0) -- (\wd\IBox,0) -- (\wd\IBox, \ht\IBox-0.5*\wd\IBox)
arc[start angle=0, end angle=180, radius={0.5\wd\IBox}] -- cycle;
\node[inner sep=0pt, above right] at (0,0) {\usebox\IBox};
\end{tikzpicture}
\end{document}
答案2
\documentclass[border=12pt]{standalone}% xelatex or lualatex
\usepackage{pstricks}
\usepackage{graphicx}
\newsavebox\IBox
\savebox\IBox{\includegraphics[width=6cm,height=6cm]{example-image}}
\begin{document}
\psset{unit=2}
\begin{pspicture}[showgrid=true](\wd\IBox,\ht\IBox)
\psclip{%
\pscustom[linestyle=none,dimen=middle]{%
\psline(\wd\IBox,0)(\wd\IBox,0.5\ht\IBox)
\psarc(0.5\wd\IBox, 0.5\ht\IBox){0.5\wd\IBox}{0}{180}
\psline(0,0)
}}
\rput(0.5\wd\IBox,0.5\ht\IBox){\usebox\IBox}
\endpsclip
\end{pspicture}
\end{document}