TikZ - 可以将图像覆盖在实体的表面上吗?

TikZ - 可以将图像覆盖在实体的表面上吗?

我知道一个人可以写作(甚至)在立体面上按照透视图进行操作,就像

用透视法写作

从绘制立方体的假(2 维)表示的代码中获得:

\documentclass[tikz,border=1cm]{standalone}
\begin{document}
\begin{tikzpicture}

\begin{scope}[every node/.append style={yslant=-0.5},yslant=-0.5]
  \shade[right color=gray!10, left color=black!50] (0,0) rectangle +(3,3);
  \node at (1.5,1.5) {\Huge 2};
\end{scope}

\begin{scope}[every node/.append style={yslant=0.5},yslant=0.5]
  \shade[right color=gray!70,left color=gray!10] (3,-3) rectangle +(3,3);
  \node at (4.5,-1.5) {\Huge 1};
\end{scope}

\begin{scope}[every node/.append style={yslant=0.5,xslant=-1},yslant=0.5,xslant=-1]
  \shade[bottom color=gray!10, top color=black!80] (6,3) rectangle +(-3,-3);
  \node at (4.5,1.5) {\Huge 3};
\end{scope}

\end{tikzpicture}
\end{document}

是否可以覆盖如下图像:

世界地图 维基百科

比如说,在立方体的两个面之上?

我知道覆盖情节但在这里不太适用。

答案1

\documentclass[tikz, border=1cm]{standalone}
\begin{document}
\begin{tikzpicture}[inner sep=0pt, outer sep=0pt, line join=bevel]
\node[draw, ultra thick, anchor=north east, yslant=-0.5] {\includegraphics[viewport={3.2cm 1.6cm 8.2cm 6.6cm}, clip]{example-image-a}};
\node[draw, ultra thick, anchor=north west, yslant=0.5] {\includegraphics[viewport={3.2cm 1.6cm 8.2cm 6.6cm}, clip]{example-image-b}};
\node[draw, ultra thick, anchor=south west, yslant=0.5, xslant=-1] {\includegraphics[viewport={3.2cm 1.6cm 8.2cm 6.6cm}, clip]{example-image-c}};
\end{tikzpicture}
\end{document}

侧面有图像的骰子

编辑:

您可以使用tikz-3dplot手动方式slant更改视角\tdplotsetmaincoords{80}{110}

\documentclass[tikz, border=1cm]{standalone}
\usepackage{tikz-3dplot}
\begin{document}
\tdplotsetmaincoords{80}{110}
\begin{tikzpicture}[tdplot_main_coords, inner sep=0pt, outer sep=0pt, line join=bevel]
\node[draw, ultra thick, transform shape, canvas is yz plane at x=1] {\includegraphics[scale=0.4, viewport={3.2cm 1.6cm 8.2cm 6.6cm}, clip]{example-image-a}};
\node[draw, ultra thick, transform shape, canvas is xz plane at y=1] {\includegraphics[scale=0.4, viewport={3.2cm 1.6cm 8.2cm 6.6cm}, clip]{example-image-b}};
\node[draw, ultra thick, transform shape, canvas is xy plane at z=1] {\includegraphics[scale=0.4, viewport={3.2cm 1.6cm 8.2cm 6.6cm}, clip]{example-image-c}};
\end{tikzpicture}
\end{document}  

骰子侧面有图像

编辑:

\documentclass[tikz, border=1cm]{standalone}
\usepackage{tikz-3dplot}
\usepackage{adjustbox}
\begin{document}
\tdplotsetmaincoords{70}{110}
\begin{tikzpicture}[tdplot_main_coords, inner sep=0pt, outer sep=0pt, line join=bevel]
\node[draw, thick, transform shape, canvas is yz plane at x=1]            {\adjustbox{trim={0.250\width} {0.333\height} {0.500\width} {0.333\height}, clip}{\includegraphics[width=8cm]{ulvyP.png}}};
\node[draw, thick, transform shape, canvas is xz plane at y=1, xscale=-1] {\adjustbox{trim={0.500\width} {0.333\height} {0.250\width} {0.333\height}, clip}{\includegraphics[width=8cm]{ulvyP.png}}};
\node[draw, thick, transform shape, canvas is xy plane at z=1, rotate=90] {\adjustbox{trim={0.250\width} {0.666\height} {0.500\width} {0.000\height}, clip}{\includegraphics[width=8cm]{ulvyP.png}}};
\end{tikzpicture}
\end{document}  

侧面有地球图像的立方体

图片来源:https://gis.stackexchange.com/questions/392282/why-does-cubemap-projection-preserve-lines-of-longitude-but-not-latitude

相关内容