如何使用 TikZ 和 LaTeX 制作不透明度

如何使用 TikZ 和 LaTeX 制作不透明度

当我用 LaTeX 编译下图时

\documentclass[border=2mm]{standalone}
\usepackage    {tikz}
\usepackage    {siunitx} 
\usetikzlibrary{3d}      
\usetikzlibrary{babel}   
\usetikzlibrary{calc}    

% \usepackage{enumitem,setspace,kantlipsum}
% ejes isométricos
%
% "How to rotate a 3D axis? Some options of the axis doesn't work"
%   https://tex.stackexchange.com/a/593507/178274
%
\pgfmathsetmacro\xx{1/sqrt(2)}
\pgfmathsetmacro\xy{1/sqrt(6)}
\pgfmathsetmacro\zy{sqrt(2/3)}


\usepackage{amsmath}
\usepackage{amssymb}

\DeclareFontEncoding{LS1}{}{}
\DeclareFontSubstitution{LS1}{stix}{m}{n}
\DeclareRobustCommand{\diameter}{%
  \text{\usefont{LS1}{stixscr}{m}{n}\symbol{"60}}%
}


\tikzset{
    ncbar angle/.initial=90,
    ncbar/.style={
        to path=(\tikztostart)
        -- ($(\tikztostart)!#1!\pgfkeysvalueof{/tikz/ncbar angle}:(\tikztotarget)$)
        -- ($(\tikztotarget)!($(\tikztostart)!#1!\pgfkeysvalueof{/tikz/ncbar angle}:(\tikztotarget)$)!\pgfkeysvalueof{/tikz/ncbar angle}:(\tikztostart)$)
        -- (\tikztotarget)
    },
    ncbar/.default=0.5cm,
}

\tikzset{square left brace/.style={ncbar=0.5cm}}
\tikzset{square right brace/.style={ncbar=-0.5cm}}

\tikzset{round left paren/.style={ncbar=0.5cm,out=120,in=-120}}
\tikzset{round right paren/.style={ncbar=0.5cm,out=60,in=-60}}


\begin{document}
\begin{tikzpicture}[x={(\xx cm,-\xy cm)},y={(\xx cm,\xy cm)},z={(0 cm,\zy cm)},% vectores i,j,k
                    thick,line cap=round,line join=round, scale=0.7]
% medidas
\def\br{1.5}  
\def\be{4}    
% estructura
\def\we{17.6} 
\def\ws{4}    

% suelo y fondo grises
\fill[canvas is yz plane at x=-\ws,gray!30] (-1.2*\ws,0)    rectangle (1.2*\ws,\we+1); % pared
\fill[canvas is xy plane at z=0   ,gray!15] (-\ws,-1.2*\ws) rectangle (7,1.2*\ws); % suelo
\draw[dashed] (0,0,\be) -- (0,0,0) -- (\ws,0,0)  node[midway,sloped, above, xshift=-0.65cm] {\SI{40}{cm}};
\fill[canvas is xy plane at z=0,gray!80] (\ws,0) circle (0.25) node[black,xshift=1.25cm] {}; %{Punto de boxeo};
\draw[canvas is xy plane at z=0,cyan, dashed] (\ws,0) circle (2.25) node[black,xshift=0.85cm, align=left] {Boxing\\ Zone};

% Saco
% la parte en forma de U del saco
\draw[fill= red!15] ($(-135:\br)+(0,0,\be+9.6)$) --++ (0,0,-9.6)
    {[canvas is xy plane at z=\be] arc (-135:45:\br)} -- ($(45:\br)+(0,0,\be+9.6)$);
% la base superior
\draw[canvas is xy plane at z=\be+9.6,fill=red!40] (0,0) circle (\br);

\foreach[count=\xi]\i in{1.5,4.2,6.9}
{%                       1.5, 1.5+2.7, 1.5+2.7+2.7
  \begin{scope}[canvas is xy plane at z=\be+\i] % dice la altura del canvas donde va la elipse
    \draw[orange] (0,0) circle (\br);
    \fill[orange] (0,0,\be+\i) circle (1pt); % centro del círculo
    \coordinate   (C\xi) at (225:\br+0.2); % son coordenadas donde pondré el final de las flechas de sección
    %--
    \foreach[evaluate={\kk={ifthenelse(\i<4, \k, \k+60)}}] \k in {0,120,240}
    {%
      \begin{scope}[rotate=\kk]  
        \draw[gray,dashed] (0,0) -- (\br,0);
        \draw[red, opacity=0.85, fill=blue!85,fill opacity=0.6,] (0.75,-0.12) rectangle (1.1,0.12);
      \end{scope}
    }
    %--
  \end{scope}
}

\draw[orange,fill= blue!40,fill opacity=0.2] ($(-135:\br)+(0,0,\be+6.9)$) --++ (0,0,-2.7)
    {[canvas is xy plane at z=\be] arc (-135:45:\br)} -- ($(45:\br)+(0,0,\be+6.9)$) {[canvas is xy plane at z=\be+6.9] arc (-135:225:-\br)};
%%%%-----
% Repito esto para que se vea bien el saco
\draw[] ($(-135:\br)+(0,0,\be+9.6)$) --++ (0,0,-9.6)
    {[canvas is xy plane at z=\be] arc (-135:45:\br)} -- ($(45:\br)+(0,0,\be+9.6)$);
\draw[canvas is xy plane at z=\be+9.6,fill=red!40] (0,0) circle (\br);
%%%%-----

\foreach\i in {0,90,180,270}
{%
  \draw[line width=0.5mm] ($(\i:\br)+(0,0,\be+9.6)$) -- (0,0,\we-0.15);
}
\draw[line width=0.5mm] (0,-\br,\be+9.6) --++ (0,0,-0.5); % enganche izquierdo
\draw[line width=0.5mm] (\br, 0,\be+9.6) --++ (0,0,-0.5); % enganche derecho

% Estructura sujección
\begin{scope}[shift={(-\ws,0,\we)},line width=1.5mm]
  \draw (0.5*\ws ,0,0) -- (0,0,-0.5*\ws) -- (0,0,-\ws); %palo horca
  \draw (0,-0.5*\ws,0) -- (0,0.5*\ws,0); %palo de arriba
  \draw (0,0,0)        -- (1.25*\ws,0,0);
  % \draw[canvas is xz plane at y=0,line width=0.75mm] (\ws,-0.15) circle (0.15);
\end{scope}
%
% % Dimensiones del saco
\begin{scope}[rotate around z=45,canvas is xz plane at y=0] % rotate around z=45 !!
  \draw[black,<->] (2*\br,\be) --++ (0,1.5) node [midway,right] {\SI{15}{cm}}; % la primera flecha con el 15
  \foreach\i in {0,1,2}
  {%
    \draw[black,dashed] (  \br,\be+1.5+2.7*\i) --++ (\br,0); %líneas dashed horizontales
    \draw[black,<->]    (2*\br,\be+1.5+2.7*\i) --++ (0,2.7) node [midway,right] {\SI{27}{cm}};
  }
  \draw[black,dashed] (\br,\be)     --++ (\br,0); % el dash line de abajo
  \draw[black,dashed] (\br,\be+9.6) --++ (\br,0); % dash line de arriba
  \draw[black] (3*\br,\be+6.9) --++ (0.5,0) --++ (0,-2.7) node [midway,right] {Punch section} --++ (-0.5,0);
\end{scope}

% % sección
\begin{scope}[x={(1cm,0cm)},y={(0cm,1cm)},shift={(-7.5,6)},very thick]
  \foreach\i in {1,2,3}
  {% % las flechas hacia las secciones
    \draw[black,-latex] (0,0) -- (C\i);
  }
  \draw[fill=white] (0,0) circle (3.1);
  % \draw (x,y) arc (start:stop:radius) % el angulo de 90 grados
  \draw[black,<->] (-60:0.5) arc (-60:60:0.5) node [midway,right] {\ang{120}};
  \foreach\i in {60,180,300}
  {%
    \begin{scope}[rotate=\i]
      \draw[gray,dashed] (0,0) -- (3.1,0);
      \draw[red, opacity=0.85, fill=blue!75,fill opacity=0.6,] (1.5,-0.22) rectangle (2.3,0.22);
    \end{scope}
  }
  % \draw[black,latex-] (0,-2) -- (0,-4) node [below, align=left] {Neoprene\\lid (open)};
  \node[black] at (-0.9,-1.5) [ align=left] {Neoprene\\lid (open)};
  % \draw[black,latex-,yshift=4, xshift=-4] (60:2) -- (-1, 4.) node [above, align=left] {ABS\\accelerometer\\cradle}; dimensions:\\Width \SI{20}{mm}\\ Length \SI{40}{mm}\\Height \SI{5}{mm}};$2\times 4\times0.5$
  \draw[black,latex-,yshift=0, xshift=-0] (60:2) -- (-1, 4) node [above, align=left] {Accelerometer board\\  \SI{2}{} $\times$ \SI{4}{} $\times$ \SI{0.5}{cm}};%\SI[product-units = single]{2 x 4 x 0.5}{cm}};
  % \SI{2}{} $\times$ \SI{4}{} $\times$ \SI{0.5}{cm}};
  \draw[black,<->]    (180:2.3) -- (180:3.1);
  \node[black] at     (-3,0) [xshift=-0.5cm,rotate=90,anchor=center, align=left] {\SI{4}{cm} to\\disk edge};
  \node[black] at     (-1.5,-3) [below=0.2cm, align=left] {Accelerometer disk\\ \(\varnothing\)\SI{31}{cm}; thickness \SI{3}{cm}};
  %{Inner\\accelerometer\\neoprene disk:\\Diameter \SI{31}{cm}\\Height \SI{3}{cm}};
\end{scope}

\begin{scope}[x={(1cm,0cm)},y={(0cm,1cm)},shift={(5, 16)},very thick]
    % \node[black] at     (0,0) [below, align=left] {Height \SI{96}{cm}\\Diameter \SI{31}{cm}\\Weight \SI{21.3}{kg}};
    \node[black] (LI) at     (0,0) [below, align=left] {Boxing bag:\\ - Height \SI{96}{cm}\\ - \(\varnothing\) \SI{31}{cm}\\ - Weight \SI{21.3}{kg}};
    \draw [black, thick, left,] ($(LI) + (-1.7,-1.3)$) to [square left brace ] ($(LI) + (-1.7,1.3)$) node[] (LI1) {};
    \draw[-latex] (-2.2,-1.3) --++ (200:1);
\end{scope}

\end{tikzpicture}
\end{document}

结果没有显示不透明度:

在此处输入图片描述

但是,如果我使用 pdfLaTeX 进行编译,则图中的不透明度会显示出来:

在此处输入图片描述

我想生成该图的 EPS 版本,但使用 LaTeX

相关内容