在 tikz 3d 中挤压形状

在 tikz 3d 中挤压形状

我想要一个从平面突出的形状,就像这里的绿色矩形油漆绘画

到目前为止我已经制作了一个这样的盒子:

\documentclass[]{article}
\usepackage{tikz}
\usetikzlibrary{3d}

\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%

\begin{document}

\begin{tikzpicture}
     [x={(1cm,-0.9cm)}, y={(5cm,0cm)}, z={(0cm,5cm)}]
 \tikzset{zxplane/.style={canvas is zx plane at y=#1,very thin}}
 \tikzset{yxplane/.style={canvas is yx plane at z=#1,very thin}}

 \begin{scope}[yxplane=-1] %bottom
   \draw (-1,-1) rectangle (1,1);
   \draw [fill=blue]  (1,0.35) rectangle (0.6,0.8);
 \end{scope}

 \begin{scope}[zxplane=-1] %left
       \draw (-1,-1) rectangle (1,1);
 \end{scope}

 \begin{scope}[zxplane=1] %right
   \draw (-1,-1) rectangle (1,1);
      \draw [fill=red] (-0.3, -0.8) rectangle (-0.25,-0.35);
 \end{scope}

 \begin{scope}[yxplane=1] %top
       \draw (-1,-1) rectangle (1,1);
     \end{scope}
 \end{tikzpicture} 

\end{document}

蒂克索法尔

是否有可能拉伸红色矩形,这样它就会从墙里出来(理想情况)。另一种选择是将蓝色矩形向上移动,这样它就与红色矩形处于同一高度,但从墙里出来。或者也许有专门的设置来处理这种事情?

如果我的代码中有错误,请见谅 - 这是我在这里找到的东西以及我反复试验的结果的大杂烩。

答案1

yxplane您可以更改以下值

\begin{scope}[yxplane=0] %middle
   \draw [fill=red] (1, 0.35) rectangle (-0.3,-1);
 \end{scope}

当你改变z值时,飞机就会向上或向下移动。

\documentclass[]{article}
\usepackage{tikz}
\usetikzlibrary{3d}

\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%

\begin{document}

\begin{tikzpicture}
     [x={(1cm,-0.9cm)}, y={(5cm,0cm)}, z={(0cm,5cm)}]
 \tikzset{zxplane/.style={canvas is zx plane at y=#1,very thin}}
 \tikzset{yxplane/.style={canvas is yx plane at z=#1,very thin}}

 \begin{scope}[yxplane=-1] %bottom
   \draw (-1,-1) rectangle (1,1);
   \draw [fill=blue]  (1,0.35) rectangle (0.6,0.8);
 \end{scope}

 \begin{scope}[yxplane=0] %middle
   \draw [fill=red] (1, 0.35) rectangle (-0.3,-1);
 \end{scope}

 \begin{scope}[zxplane=-1] %left
       \draw (-1,-1) rectangle (1,1);
 \end{scope}

 \begin{scope}[zxplane=1] %right
   \draw (-1,-1) rectangle (1,1);

 \end{scope}

 \begin{scope}[yxplane=1] %top
       \draw (-1,-1) rectangle (1,1);
     \end{scope}
 \end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容