我从这个网站获取了代码。我想用 3D 洋红色填充底部。该怎么做?
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}
\draw[thick,fill=magenta,magenta] (0,0) rectangle (12,4.5);
\draw[thick, fill=white!30] (0,0) rectangle (1,1) (12,0) rectangle (11,1)
(12,4.5) rectangle node[below=5mm]{$x$}node[left=5mm]{$x$} (11,3.5) (0,4.5) rectangle (1,3.5);
\draw[semithick, dashed] (1,1) rectangle (11,3.5);
\draw[thick, {Bar[width=8mm]Latex}-{{Latex}Bar[width=8mm]}] (0,-.5) --node[fill=white]{24} (12,-.5);
\draw[thick, {Bar[width=8mm]Latex}-{{Latex}Bar[width=8mm]}] (12.5,0) --node[fill=white]{9} (12.5,4.5);
\begin{scope}[shift={(0,-6)}, line join=round]
\draw[thick,fill=magenta] ([shift={(2,2)}]1,1) rectangle ([shift={(2,2)}]11,2);
\draw[thick,fill=magenta] (1,1) -- ([shift={(2,2)}]1,1) -- ([shift={(2,2)}]1,2) -- (1,2) -- cycle;
\draw[thick,fill=magenta] (1,1) rectangle (11,2);
\draw[thick,fill=magenta] (11,1) -- ([shift={(2,2)}]11,1) --node[right=2.5mm]{$x$} ([shift={(2,2)}]11,2) -- (11,2) -- cycle;
\draw[thick, {Bar[width=8mm]Latex}-{{Latex}Bar[width=8mm]}] (1,.5) --node[fill=white]{$24-2x$} (11,.5);
\draw[thick] ([shift={(2,2)}]11,.9)--([shift={(2,2)}]11,.1);
\draw[thick,magenta, {Latex[slant=1]}-{Latex[slant=1]}] (11,.5) --node[inner sep=0](M){} ([shift={(2,2)}]11,.5);
\draw[Latex-] (M)--++(1,-1)node[below]{$9-2x$};
\draw[thick, -{{Latex}Bar[width=8mm]}] ([shift={(2,2)}]11.5,2.5)--([shift={(2,2)}]11.5,2);
\draw[thick, -{{Latex}Bar[width=8mm]}] ([shift={(2,2)}]11.5,.5)--([shift={(2,2)}]11.5,1);
\end{scope}
\end{tikzpicture}
\end{document}
答案1
这是你想要的吗?(考虑到 Black Mild 的建议):
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}
\draw[thick,fill=magenta,magenta] (0,0) rectangle (12,4.5);
\draw[thick, fill=white!30] (0,0) rectangle (1,1) (12,0) rectangle (11,1)
(12,4.5) rectangle node[below=5mm]{$x$}node[left=5mm]{$x$} (11,3.5) (0,4.5) rectangle (1,3.5);
\draw[semithick, dashed] (1,1) rectangle (11,3.5);
\draw[thick, {Bar[width=8mm]Latex}-{{Latex}Bar[width=8mm]}] (0,-.5) --node[fill=white]{24} (12,-.5);
\draw[thick, {Bar[width=8mm]Latex}-{{Latex}Bar[width=8mm]}] (12.5,0) --node[fill=white]{9} (12.5,4.5);
\begin{scope}[shift={(0,-6)}, line join=round]
\fill[magenta,opacity=0.6] (3,3) -- (2,2) -- (11,2) -- (12,3) -- cycle; % <<<<< here is the coloring of the bottom you can change color or opacity if you want.
\draw[thick,fill=magenta] ([shift={(2,2)}]1,1) rectangle ([shift={(2,2)}]11,2);
\draw[thick,fill=magenta] (1,1) -- ([shift={(2,2)}]1,1) -- ([shift={(2,2)}]1,2) -- (1,2) -- cycle;
\draw[thick,fill=magenta] (1,1) rectangle (11,2);
\draw[thick,fill=magenta] (11,1) -- ([shift={(2,2)}]11,1) --node[right=2.5mm]{$x$} ([shift={(2,2)}]11,2) -- (11,2) -- cycle;
\draw[thick, {Bar[width=8mm]Latex}-{{Latex}Bar[width=8mm]}] (1,.5) --node[fill=white]{$24-2x$} (11,.5);
\draw[thick] ([shift={(2,2)}]11,.9)--([shift={(2,2)}]11,.1);
\draw[thick,magenta, {Latex[slant=1]}-{Latex[slant=1]}] (11,.5) --node[inner sep=0](M){} ([shift={(2,2)}]11,.5);
\draw[Latex-] (M)--++(1,-1)node[below]{$9-2x$};
\draw[thick, -{{Latex}Bar[width=8mm]}] ([shift={(2,2)}]11.5,2.5)--([shift={(2,2)}]11.5,2);
\draw[thick, -{{Latex}Bar[width=8mm]}] ([shift={(2,2)}]11.5,.5)--([shift={(2,2)}]11.5,1);
\end{scope}
\end{tikzpicture}
\end{document}