![使用 pst-3dplot 绘制挤压物体](https://linux22.com/image/277315/%E4%BD%BF%E7%94%A8%20pst-3dplot%20%E7%BB%98%E5%88%B6%E6%8C%A4%E5%8E%8B%E7%89%A9%E4%BD%93.png)
我想画一个中间有一个洞的平面。到目前为止,我只通过在平面中间绘制一个白色椭圆来解决这个问题。然而,我希望这个洞实际上是一个透明的区域,而不是白色的。这是我的 mwe
\documentclass[11pt]{article}
\usepackage{pstricks-add}
\usepackage{auto-pst-pdf}
\usepackage{pst-3dplot}
\begin{document}
\begin{pspicture}(-5,-5)(5,5)
\pstThreeDSquare[fillcolor=red,fillstyle=solid](0,0,0)(0,2,0)(2,0,0)
\pstThreeDSquare[fillcolor=blue,fillstyle=solid](0,0,0.8)(0,2,0)(2,0,0)
\pstThreeDEllipse[fillcolor=white,fillstyle=solid](1,1,0.8)(0,0.5,0)(0.5,0,0)
\end{pspicture}
\end{document}
我希望白色椭圆实际上是透明的。这可能吗?
答案1
蓝色正方形也必须是透明的,因为圆圈在蓝色上而不是红色上:
\documentclass[11pt]{article}
\usepackage{auto-pst-pdf}
\usepackage{pst-3dplot}
\begin{document}
\begin{pspicture}(-5,-5)(5,5)
\pstThreeDSquare[fillcolor=red,fillstyle=solid](0,0,0)(0,2,0)(2,0,0)
\pstThreeDSquare[fillcolor=blue,fillstyle=solid,opacity=0.5](0,0,0.8)(0,2,0)(2,0,0)
\pstThreeDEllipse[fillcolor=white,fillstyle=solid,opacity=0.5](1,1,0.8)(0,0.5,0)(0.5,0,0)
\end{pspicture}
\end{document}
如果您希望圆形部分被完全剪掉,则必须使用\pscustom
蓝色填充区域:
\documentclass[pstricks]{standalone}
\usepackage{pst-3dplot}
\begin{document}
\begin{pspicture}(-2,-2)(2,1)
\pstThreeDSquare[fillcolor=red,fillstyle=solid](0,0,0)(0,2,0)(2,0,0)
\pscustom[fillcolor=blue,fillstyle=solid,opacity=0.5,linestyle=none]{%
\pstThreeDLine(0,2,0.8)(0,0,0.8)(2,0,0.8)(2,2,0.8)(1,2,0.8)(1,1.5,0.8)%3 1/2 lines and a line to the circle
\pstThreeDEllipse(1,1,0.8)(0,0.5,0)(0.5,0,0)
\pstThreeDLine(1,1.5,0.8)(1,2,0.8)(0,2,0.8)% Back to the square
}
\pstThreeDSquare(0,0,0.8)(0,2,0)(2,0,0)
\pstThreeDEllipse(1,1,0.8)(0,0.5,0)(0.5,0,0)
\end{pspicture}
\end{document}
答案2
外行人可以用 来解答tikz
。
\documentclass{article}
\usepackage{tikz}
\begin{document}
\tikzset{
invclip/.style={
clip,
insert path={{[reset cm](-16383.99999pt,-16383.99999pt) rectangle (16383.99999pt,16383.99999pt)}}
}
}
%
\begin{tikzpicture}
\draw[fill = red, opacity = 0.5] (-4,0) -- (0,-2) -- (4,0) -- (0,2) -- cycle;
\begin{scope}[yshift=2cm]
\begin{pgfinterruptboundingbox}
\path [invclip] (0,2) circle (1.5cm and .75cm);
\end{pgfinterruptboundingbox}
\draw[fill = blue, opacity = 0.5] (-4,0) -- (0,-2) -- (4,0) -- (0,2) -- cycle;
\end{scope}
\end{tikzpicture}
%
\end{document}
答案3
仅用于使用 PSTricks 进行打字练习。
\documentclass[pstricks,border=12pt]{standalone}
\begin{document}
\begin{pspicture}(6,6)
\pspolygon[fillstyle=solid,fillcolor=red](0,2)(3,0)(6,2)(3,4)
\pscustom[fillcolor=blue,opacity=.5,fillstyle=eofill]
{
\translate(0,2)
\pspolygon(0,2)(3,0)(6,2)(3,4)
\moveto(4.5,2)
\psellipse(3,2)(1.5,.5)
}
\end{pspicture}
\end{document}