Quantcast
Channel: Tikz : texture cube faces using png image - TeX - LaTeX Stack Exchange
Viewing all articles
Browse latest Browse all 3

Tikz : texture cube faces using png image

$
0
0

I would like to draw a cube using Tikz with some faces of the cube having a texture on it (texture would be a PNG image)

my current code is at follows :

\documentclass{standalone}\usepackage{tikz}\usetikzlibrary{3d,calc}\tikzset{persp/.style={scale=3.0,x={(-0.8cm,-0.4cm)},y={(0.8cm,-0.4cm)}, z={(0cm,1cm)}},points/.style={fill=white,draw=black,thick}}\begin{document}\begin{tikzpicture}[persp]\def\i{-15}    \pgfmathparse{cos(\i)}\let\ci\pgfmathresult    \pgfmathparse{sin(\i)}\let\si\pgfmathresult     \coordinate (Ocube) at (0,0,0);    \coordinate (Xcube) at (\ci,\si,0);    \coordinate (Ycube) at (-\si,\ci,0);    \coordinate (Zcube) at (0,0,1);    \coordinate (C0) at ($(Ocube)-(Xcube)-(Ycube)-(Zcube)$);    \coordinate (C1) at ($(Ocube)+(Xcube)-(Ycube)-(Zcube)$);    \coordinate (C2) at ($(Ocube)-(Xcube)+(Ycube)-(Zcube)$);    \coordinate (C3) at ($(Ocube)+(Xcube)+(Ycube)-(Zcube)$);    \coordinate (C4) at ($(Ocube)-(Xcube)-(Ycube)+(Zcube)$);    \coordinate (C5) at ($(Ocube)+(Xcube)-(Ycube)+(Zcube)$);    \coordinate (C6) at ($(Ocube)-(Xcube)+(Ycube)+(Zcube)$);    \coordinate (C7) at ($(Ocube)+(Xcube)+(Ycube)+(Zcube)$);    \fill[black!20, draw=black, dashed,opacity=0.3] (C0)--(C1)--(C3)--(C2)--cycle;    \fill[black!20, draw=black, dashed,opacity=0.3] (C0)--(C1)--(C5)--(C4)--cycle;    \fill[black!20, draw=black, dashed,opacity=0.3] (C0)--(C2)--(C6)--(C4)--cycle;    \fill[black!20, draw=black, thick,opacity=0.3] (C4)--(C5)--(C7)--(C6)--cycle;    \fill[black!20, draw=black, thick,opacity=0.3] (C2)--(C3)--(C7)--(C6)--cycle;    \fill[black!20, draw=black, thick,opacity=0.3] (C1)--(C3)--(C7)--(C5)--cycle;       \coordinate (Q0) at ($(Ocube)-.8*(Xcube)+(Ycube)-.8*(Zcube)$);    \coordinate (Q1) at ($(Ocube)+.8*(Xcube)+(Ycube)-.8*(Zcube)$);    \coordinate (Q2) at ($(Ocube)-.8*(Xcube)+(Ycube)+.8*(Zcube)$);    \coordinate (Q3) at ($(Ocube)+.8*(Xcube)+(Ycube)+.8*(Zcube)$);    \fill[white!20, draw=black, thick,opacity=0.3] (Q0)--(Q1)--(Q3)--(Q2)--cycle;\end{tikzpicture}\end{document}

On the last line, rather then filling white a color (white!20), I would like to draw the image "face.png". This drawing must be distorded so to fit the face realisticaly.

Could someone help me doing that ?


Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>