6

I have a few graphics which I believe are good enough to show what I need but I want to go further, I am wondering what kind of settings could be used in the \shade[] command to create a 3D effect.

The MWE is the drawing of a red light I would like to it look like this png graphic

Redlight

\documentclass[11pt,a4paper]{article}
\usepackage{tikz}
\begin{document}
            \begin{tikzpicture}
            \draw[rounded corners,fill=yellow!80!brown] (-1,4)rectangle++ (2.5,3);
            \draw[rounded corners,fill=gray] (-0.8,4.2)rectangle++ (2.1,2.6);
            \draw[fill=red] (0.25,6.3)circle [radius=8pt];
            \draw[fill=yellow] (0.25,5.5)circle [radius=8pt];
            \draw[fill=green] (0.25,4.7)circle [radius=8pt];
            \draw[fill=yellow!80!brown] (0,0)rectangle++ (0.5,4);
            \end{tikzpicture}
\end{document}
9
  • 1
    If you want it to look like that, why not use \includegraphics? TikZ is not good at 3D. There is no support for lighting, for example. If you want that, use a proper 3D tool. Of course, you can use TikZ because you can paint pixel-by-pixel, if you must, but why would you do that?
    – cfr
    Mar 31, 2018 at 2:17
  • 1
    ball color=red etc. will give you something a bit more 3D like for the lights. But the way the light is falling ... there's just no reason to do that in TikZ.
    – cfr
    Mar 31, 2018 at 2:18
  • With a fair amount of fine-tuning, you will be able to achieve this. If you do not like to fine-tune, you may want to consider switching to asymptote.
    – user121799
    Mar 31, 2018 at 2:19
  • 1
    Vector version of image is available at openclipart.org/detail/118837/traffic-light-dan-gerhar-01 (presumably the source of the image in the question).
    – cfr
    Mar 31, 2018 at 2:22
  • 1
    The image I linked is the same picture you posted, but available in vector (or high res raster format). I don't know what you mean re. 'same quality', but including the PDF there in your document will get you as good quality as you are going to get and considerably better than you are likely to do manually with TikZ. Or download the SVG and convert it, though I tried this and the PDF will give much more satisfactory results. What you are asking here is a pointless waste of time. The very image you want is already available as high quality vector. You haven't given any reason not to use it.
    – cfr
    Mar 31, 2018 at 2:47

3 Answers 3

11

This is what I was able to do in 20 + 10 minutes... the remaining fine-tuning would take quite a bit longer. EDIT: Added shadows.

enter image description here

\documentclass[tikz,border=3.14pt]{standalone}
\usetikzlibrary{shadings}

\newcommand{\translight}[1]{\begin{scope}[#1]
\shade[top color=gray,bottom color=black] (0,0) -- ++ (1.9,0) -- ++ (0,-1.9) -- ++(-0.8,0) to
[out=90,in=-90] ++(-1.1,1.7) -- cycle;
\draw[fill=black!80!gray] (1.9,0.3) -- ++(0.2,0) -- ++(0,-2.4) -- ++(-0.2,0) -- cycle;
\end{scope}
}
\newcommand{\bulb}[2][]{\begin{scope}[#1]
\draw[thick,fill=black!80!gray] (-1.2,-1.4) coordinate (bl) rectangle ++(2.4,2.2)
coordinate (tr);
\shade[ball color=#2] (0,-0.2) circle (0.9);
\draw[fill=black!97!gray] (bl) -- ++ (-0.12,-0.12) -- ++(2.64,0) -- (bl-|tr) -- cycle;
\draw[fill=black!98!gray] (bl-|tr) -- ++ (0.12,-0.12) -- ++(0,2.44) -- (tr) -- cycle;
\draw[fill=black!50!gray] (tr-|bl) -- ++ (-0.12,0.12) -- ++(2.64,0) -- (tr) -- cycle;
\draw[fill=black!50!gray] (tr-|bl) -- ++ (-0.12,0.12) -- ++(0,-2.44)
-- (bl) -- cycle;
\end{scope}
}

\begin{document}
\begin{tikzpicture}
\draw[fill=black!90!gray] (-1.5,-4.3) rectangle (1.5,3.6);
\bulb[shift={(0,2.4)}]{orange!10!red}
\bulb[shift={(0,0)}]{orange!50!yellow}
\bulb[shift={(0,-2.4)}]{green!70!black}
\translight{shift={(-3.6,3.2)}}
\translight{shift={(-3.6,0.7)}}
\translight{shift={(-3.6,-1.9)}}
%\translight{shift={(3.6,3.2)},xscale=-1}
\begin{scope}[shift={(3.6,3.2)},xscale=-1]
\draw[fill=black!80!gray] (1.9,0.3) -- ++(0.2,0) -- ++(0,-2.4) -- ++(-0.2,0) -- cycle;
\shade[top color=gray,bottom color=black,clip] (0,0) -- ++ (1.9,0) -- ++ (0,-1.9) -- ++(-0.8,0) to
[out=90,in=-90] ++(-1.1,1.7) -- cycle;
\fill[gray!20!black,opacity=0.3] (1.9,0) -- ++(-0.2,0) -- ++ (-1.8,-1.8) -- ++ (2,0) -- cycle;
\end{scope}
%\translight{shift={(3.6,0.7)},xscale=-1}
\begin{scope}[shift={(3.6,0.7)},xscale=-1]
\draw[fill=black!80!gray] (1.9,0.3) -- ++(0.2,0) -- ++(0,-2.4) -- ++(-0.2,0) -- cycle;
\shade[top color=gray,bottom color=black,clip] (0,0) -- ++ (1.9,0) -- ++ (0,-1.9) -- ++(-0.8,0) to
[out=90,in=-90] ++(-1.1,1.7) -- cycle;
\fill[gray!20!black,opacity=0.3] (1.9,0) rectangle ++ (-2,-2);
\end{scope}
%\translight{shift={(3.6,-1.9)},xscale=-1}
\begin{scope}[shift={(3.6,-1.9)},xscale=-1]
\draw[fill=black!80!gray] (1.9,0.3) -- ++(0.2,0) -- ++(0,-2.4) -- ++(-0.2,0) -- cycle;
\shade[top color=gray,bottom color=black,clip] (0,0) -- ++ (1.9,0) -- ++ (0,-1.9) -- ++(-0.8,0) to
[out=90,in=-90] ++(-1.1,1.7) -- cycle;
\fill[gray!20!black,opacity=0.3] (1.9,0) rectangle ++ (-2,-2);
\end{scope}
%
\shade[ball color=gray!50!black] (1.1,3.6) -- (-1.1,3.6) to[out=90,in=90] cycle;

\end{tikzpicture}
\end{document}

Note that I am living in a different time zone, so the position of the sun is a bit different from what it is in your picture. If you're not happy with it, please have a look at this post where it is explained how to customize the angle.

UPDATE: For our ducks. Inspired by Ulrike Fischer's duck light. (At the time of writing the below code, I had forgotten about Ulrike's post, but clearly I had seen it before.)

\documentclass{article}
\usepackage{animate}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[active,tightpage]{preview}
\makeatletter
\def\@anim@@newframe{\@ifstar\@anim@newframe\@anim@newframe}
\def\@anim@newframe{\end{preview}\begin{preview}}
\renewenvironment{animateinline}[2][]{%
  \let\newframe\@anim@@newframe%
  \let\multiframe\@anim@multiframe%
  \begin{preview}}{%
  \end{preview}}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



\usepackage{tikz}
\usetikzlibrary{shadings}

\newcommand{\translight}[1]{\begin{scope}[#1]
\shade[top color=gray,bottom color=black] (0,0) -- ++ (1.9,0) -- ++ (0,-1.9) -- ++(-0.8,0) to
[out=90,in=-90] ++(-1.1,1.7) -- cycle;
\draw[fill=black!80!gray] (1.9,0.3) -- ++(0.2,0) -- ++(0,-2.4) -- ++(-0.2,0) -- cycle;
\end{scope}
}
\newcommand{\bulbback}[2][]{\begin{scope}[#1]
\draw[thick,fill=black!80!gray] (-1.2,-1.4) coordinate (bl) rectangle ++(2.4,2.2)
coordinate (tr);

\draw[fill=black!97!gray] (bl) -- ++ (-0.12,-0.12) -- ++(2.64,0) -- (bl-|tr) -- cycle;
\draw[fill=black!98!gray] (bl-|tr) -- ++ (0.12,-0.12) -- ++(0,2.44) -- (tr) -- cycle;
\draw[fill=black!50!gray] (tr-|bl) -- ++ (-0.12,0.12) -- ++(2.64,0) -- (tr) -- cycle;
\draw[fill=black!50!gray] (tr-|bl) -- ++ (-0.12,0.12) -- ++(0,-2.44)
-- (bl) -- cycle;

\end{scope}
}
\newcommand{\bulbduck}[2][]{\begin{scope}[#1]
\begin{scope}[xshift=-18,yshift=-21,scale=0.6]% from the tikzducks package
\draw[clip]
  (0.513,1.145) .. controls (0.267, 1.102) and (-0.125,0.657) .. (0.289,0.261)
  (0.289,0.261) .. controls (0.704,-0.135) and ( 2.863,0.130) .. (1.818,1.419)
        -- (1.35,1.20) arc (-30:185:0.50 and 0.625) --(0.406,1.472)
         .. controls (0.269,1.369) and (0.083,0.850) .. (0.600,1.300)
         --(0.513,1.145)
         -- cycle;
\ifcase#2
\shade[ball color=orange!10!red] (1.1,1.2) circle (1.6);
\or
\shade[ball color=orange!50!yellow] (1.1,1.2) circle (1.6);
\or
\shade[ball color=green!70!black] (1.1,1.2) circle (1.6);
\fi
\end{scope}
\end{scope}
}
\def\X{3}
\begin{document}
\begin{animateinline}[autoplay,loop]{2}
\multiframe{4}{i=1+1}{\pgfmathtruncatemacro{\X}{\i-1}
\begin{tikzpicture}
\draw[fill=black!90!gray] (-1.5,-4.3) rectangle (1.5,3.6);
\bulbback[shift={(0,2.4)}]{0}
\bulbback[shift={(0,0)}]{1}
\bulbback[shift={(0,-2.4)}]{2}
\ifcase\X
\bulbduck[shift={(0,2.2)}]{0}
\or
\bulbduck[shift={(0,2.2)}]{0}
\bulbduck[shift={(0,-0.2)}]{1}
\or
\bulbduck[shift={(0,-2.6)}]{2}
\or
\bulbduck[shift={(0,-0.2)}]{1}
\fi
\translight{shift={(-3.6,3.2)}}
\translight{shift={(-3.6,0.7)}}
\translight{shift={(-3.6,-1.9)}}
%\translight{shift={(3.6,3.2)},xscale=-1}
\begin{scope}[shift={(3.6,3.2)},xscale=-1]
\draw[fill=black!80!gray] (1.9,0.3) -- ++(0.2,0) -- ++(0,-2.4) -- ++(-0.2,0) -- cycle;
\shade[top color=gray,bottom color=black,clip] (0,0) -- ++ (1.9,0) -- ++ (0,-1.9) -- ++(-0.8,0) to
[out=90,in=-90] ++(-1.1,1.7) -- cycle;
\fill[gray!20!black,opacity=0.3] (1.9,0) -- ++(-0.2,0) -- ++ (-1.8,-1.8) -- ++ (2,0) -- cycle;
\end{scope}
%\translight{shift={(3.6,0.7)},xscale=-1}
\begin{scope}[shift={(3.6,0.7)},xscale=-1]
\draw[fill=black!80!gray] (1.9,0.3) -- ++(0.2,0) -- ++(0,-2.4) -- ++(-0.2,0) -- cycle;
\shade[top color=gray,bottom color=black,clip] (0,0) -- ++ (1.9,0) -- ++ (0,-1.9) -- ++(-0.8,0) to
[out=90,in=-90] ++(-1.1,1.7) -- cycle;
\fill[gray!20!black,opacity=0.3] (1.9,0) rectangle ++ (-2,-2);
\end{scope}
%\translight{shift={(3.6,-1.9)},xscale=-1}
\begin{scope}[shift={(3.6,-1.9)},xscale=-1]
\draw[fill=black!80!gray] (1.9,0.3) -- ++(0.2,0) -- ++(0,-2.4) -- ++(-0.2,0) -- cycle;
\shade[top color=gray,bottom color=black,clip] (0,0) -- ++ (1.9,0) -- ++ (0,-1.9) -- ++(-0.8,0) to
[out=90,in=-90] ++(-1.1,1.7) -- cycle;
\fill[gray!20!black,opacity=0.3] (1.9,0) rectangle ++ (-2,-2);
\end{scope}
%
\shade[ball color=gray!50!black] (1.1,3.6) -- (-1.1,3.6) to[out=90,in=90] cycle;
%
\end{tikzpicture}
}
\end{animateinline}
\end{document}

enter image description here

6
  • @Tarass I agree but not even the OP's traffic light is too realistic
    – user121799
    Mar 31, 2018 at 16:49
  • You did a great job. It was just a joke.
    – Tarass
    Mar 31, 2018 at 16:50
  • @Tarass Thanks for the encouragement! ;-) I added some shadows. Clearly, this traffic light is lacking a duck!
    – user121799
    Mar 31, 2018 at 17:33
  • One could add a shadow of a duck.
    – Tarass
    Mar 31, 2018 at 17:51
  • But why are there many ducks anywhere on the site to get help too?:-)+1
    – Sebastiano
    Apr 1, 2018 at 11:28
5

TikZ is not good at 3D. In particular, it has no support for lighting - no concept of a light source, of shadows etc. Faking is always possible - painting pixel-by-pixel, if you like - but a pointless waste of time.

If you really need to draw this yourself, use a tool designed for 3D which can handle light sources. Asymptote has been mentioned, but there are probably better options. Asymptote is good if you create it as a 2D image, but will insist on raster output if you switch to 3D.

However, for this image, the effort is really pointless, as high resolution raster and vector is already available from https://openclipart.org/detail/118837/traffic-light-dan-gerhar-01. Downloading the PDF and using \includegraphics is the painless path to excellent quality here. Alternatively, you can try downloading the SVG and converting it. My initial attempt with Inkscape wasn't overly successful, but you may do better by fine-tuning things.

Inkscape output

For reference, here is what my attempt with Inkscape yielded. I guess there are tricks to this, but these are left as an exercise for the reader. Which is to say, I don't know what they are - my conversions are very hit-or-miss, with more misses than hits, unfortunately. (The donkey worked fine; the don-key and the traffic lights rather less so.)

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}

\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}

\begin{document}
\definecolor{c242424}{RGB}{36,36,36}
\definecolor{c4c4c4c}{RGB}{76,76,76}

\begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-1.000000, xscale=1.000000, inner sep=0pt, outer sep=0pt]
\begin{scope}[shift={(-29.144,-25.155)}]
  \begin{scope}[shift={(-97.143,-117.14)}]
    \path[cm={{0.91993,0.0,0.0,1.1621,(18.431,13.418)}},color=black]
      (535.3808,160.3975)arc(-0.000:90.000:100.005100 and
      49.497)arc(90.000:180.000:100.005100 and 49.497)arc(180.000:270.000:100.005100
      and 49.497)arc(270.000:360.000:100.005100 and 49.497) -- cycle;
    \path[color=black,rounded corners=0.0000cm] (300.0000,193.1500) rectangle
      (536.0700,828.7100);
        \path[color=black,fill=c242424,rounded corners=0.0000cm] (317.8600,205.2200)
          rectangle (520.0000,407.3600);
        \path[fill=c4c4c4c,even odd rule] (520.2500,204.9800) -- (318.1400,204.9800) --
          (326.3100,213.1500) -- (512.0900,213.1500) -- (520.2500,204.9800) -- cycle;
        \path[fill=black,even odd rule] (520.2500,407.6000) -- (317.6400,407.6000) --
          (325.8100,399.4300) -- (512.0900,399.4300) -- (520.2500,407.6000) -- cycle;
        \path[fill=black,even odd rule] (317.6400,204.4800) -- (317.6400,407.6000) --
          (325.8100,399.4300) -- (325.8100,212.6400) -- (317.6400,204.4800) -- cycle;
        \path[fill=c4c4c4c,even odd rule] (520.2500,204.9800) -- (520.2500,407.6000) --
          (512.0900,399.4300) -- (512.0900,213.1500) -- (520.2500,204.9800) -- cycle;
      \begin{scope}[shift={(0,-0.2529)}]
        \path[cm={{1.4033,0.0,0.0,1.4033,(-154.44,-176.16)}},color=black]
          (462.8571,343.7907)arc(0.000:90.000:54.286)arc(90.000:180.000:54.286)arc(180.000:270.000:54.286)arc(270.000:360.000:54.286)
          -- cycle;
        \path[cm={{1.4033,0.0,0.0,1.4033,(-154.44,-176.16)}},color=black,draw=black,line
          join=round,line cap=round,line width=4.276pt]
          (462.8571,343.7907)arc(0.000:90.000:54.286)arc(90.000:180.000:54.286)arc(180.000:270.000:54.286)arc(270.000:360.000:54.286)
          -- cycle;
      \end{scope}
      \begin{scope}[shift={(0,205.0)}]
        \path[color=black,fill=c242424,rounded corners=0.0000cm] (317.8600,205.2200)
          rectangle (520.0000,407.3600);
        \path[fill=c4c4c4c,even odd rule] (520.2500,204.9800) -- (318.1400,204.9800) --
          (326.3100,213.1500) -- (512.0900,213.1500) -- (520.2500,204.9800) -- cycle;
        \path[fill=black,even odd rule] (520.2500,407.6000) -- (317.6400,407.6000) --
          (325.8100,399.4300) -- (512.0900,399.4300) -- (520.2500,407.6000) -- cycle;
        \path[fill=black,even odd rule] (317.6400,204.4800) -- (317.6400,407.6000) --
          (325.8100,399.4300) -- (325.8100,212.6400) -- (317.6400,204.4800) -- cycle;
        \path[fill=c4c4c4c,even odd rule] (520.2500,204.9800) -- (520.2500,407.6000) --
          (512.0900,399.4300) -- (512.0900,213.1500) -- (520.2500,204.9800) -- cycle;
      \end{scope}
      \begin{scope}[shift={(0,3.247)}]
        \path[cm={{1.4033,0.0,0.0,1.4033,(-154.44,25.336)}},color=black]
          (462.8571,343.7907)arc(0.000:90.000:54.286)arc(90.000:180.000:54.286)arc(180.000:270.000:54.286)arc(270.000:360.000:54.286)
          -- cycle;
        \path[cm={{1.4033,0.0,0.0,1.4033,(-154.44,25.336)}},color=black,draw=black,line
          join=round,line cap=round,line width=4.276pt]
          (462.8571,343.7907)arc(0.000:90.000:54.286)arc(90.000:180.000:54.286)arc(180.000:270.000:54.286)arc(270.000:360.000:54.286)
          -- cycle;
      \end{scope}
      \begin{scope}[shift={(0,410.0)}]
        \path[color=black,fill=c242424,rounded corners=0.0000cm] (317.8600,205.2200)
          rectangle (520.0000,407.3600);
        \path[fill=c4c4c4c,even odd rule] (520.2500,204.9800) -- (318.1400,204.9800) --
          (326.3100,213.1500) -- (512.0900,213.1500) -- (520.2500,204.9800) -- cycle;
        \path[fill=black,even odd rule] (520.2500,407.6000) -- (317.6400,407.6000) --
          (325.8100,399.4300) -- (512.0900,399.4300) -- (520.2500,407.6000) -- cycle;
        \path[fill=black,even odd rule] (317.6400,204.4800) -- (317.6400,407.6000) --
          (325.8100,399.4300) -- (325.8100,212.6400) -- (317.6400,204.4800) -- cycle;
        \path[fill=c4c4c4c,even odd rule] (520.2500,204.9800) -- (520.2500,407.6000) --
          (512.0900,399.4300) -- (512.0900,213.1500) -- (520.2500,204.9800) -- cycle;
      \end{scope}
      \begin{scope}[shift={(0.01812,4.247)}]
        \path[cm={{1.4033,0.0,0.0,1.4033,(-154.44,229.34)}},color=black]
          (462.8571,343.7907)arc(0.000:90.000:54.286)arc(90.000:180.000:54.286)arc(180.000:270.000:54.286)arc(270.000:360.000:54.286)
          -- cycle;
        \path[cm={{1.4033,0.0,0.0,1.4033,(-154.44,229.34)}},color=black,draw=black,line
          join=round,line cap=round,line width=4.276pt]
          (462.8571,343.7907)arc(0.000:90.000:54.286)arc(90.000:180.000:54.286)arc(180.000:270.000:54.286)arc(270.000:360.000:54.286)
          -- cycle;
      \end{scope}
    \begin{scope}[shift={(14.0,0)}]
      \path[color=black,draw=black,line cap=round,line width=6.000pt]
        (547.2900,790.9300) -- (548.7100,640.2200) -- (692.2900,640.2200) .. controls
        (691.7400,674.7900) and (699.9500,686.2100) .. (646.7800,729.9900) .. controls
        (618.7100,753.1100) and (604.3400,759.5500) .. (603.0000,790.9300) --
        (547.2900,790.9300) -- cycle;
      \path[color=black,fill=c242424,rounded corners=0.0000cm] (522.2900,615.0000)
        rectangle (538.0040,817.5400);
      \path[fill=c4c4c4c,even odd rule] (537.9600,614.9800) -- (537.9600,817.6000) --
        (546.1300,809.4300) -- (546.1300,623.1500) -- (537.9600,614.9800) -- cycle;
    \end{scope}
    \begin{scope}[shift={(14.0,-410.0)}]
      \path[color=black,draw=black,line cap=round,line width=6.000pt]
        (547.2900,790.9300) -- (548.7100,640.2200) -- (692.2900,640.2200) .. controls
        (691.7400,674.7900) and (699.9500,686.2100) .. (646.7800,729.9900) .. controls
        (618.7100,753.1100) and (604.3400,759.5500) .. (603.0000,790.9300) --
        (547.2900,790.9300) -- cycle;
      \path[color=black,fill=c242424,rounded corners=0.0000cm] (522.2900,615.0000)
        rectangle (538.0040,817.5400);
      \path[fill=c4c4c4c,even odd rule] (537.9600,614.9800) -- (537.9600,817.6000) --
        (546.1300,809.4300) -- (546.1300,623.1500) -- (537.9600,614.9800) -- cycle;
\end{scope}
\begin{scope}[shift={(14.0,-205.0)}]
  \path[color=black,draw=black,line cap=round,line width=6.000pt]
    (547.2900,790.9300) -- (548.7100,640.2200) -- (692.2900,640.2200) .. controls
    (691.7400,674.7900) and (699.9500,686.2100) .. (646.7800,729.9900) .. controls
    (618.7100,753.1100) and (604.3400,759.5500) .. (603.0000,790.9300) --
    (547.2900,790.9300) -- cycle;
  \path[color=black,fill=c242424,rounded corners=0.0000cm] (522.2900,615.0000)
    rectangle (538.0040,817.5400);
  \path[fill=c4c4c4c,even odd rule] (537.9600,614.9800) -- (537.9600,817.6000) --
    (546.1300,809.4300) -- (546.1300,623.1500) -- (537.9600,614.9800) -- cycle;
\end{scope}
\begin{scope}[cm={{-1.0,0.0,0.0,1.0,(822.49,0.0)}}]
  \path[color=black,draw=black,line cap=round,line width=6.000pt]
    (547.2900,790.9300) -- (548.7100,640.2200) -- (692.2900,640.2200) .. controls
    (691.7400,674.7900) and (699.9500,686.2100) .. (646.7800,729.9900) .. controls
    (618.7100,753.1100) and (604.3400,759.5500) .. (603.0000,790.9300) --
    (547.2900,790.9300) -- cycle;
  \path[color=black,fill=c242424,rounded corners=0.0000cm] (522.2900,615.0000)
    rectangle (538.0040,817.5400);
  \path[fill=black,even odd rule] (537.9600,614.9800) -- (537.9600,817.6000) --
    (546.1300,809.4300) -- (546.1300,623.1500) -- (537.9600,614.9800) -- cycle;
\end{scope}
\begin{scope}[cm={{-1.0,0.0,0.0,1.0,(822.49,-410.0)}}]
  \path[color=black,draw=black,line cap=round,line width=6.000pt]
    (547.2900,790.9300) -- (548.7100,640.2200) -- (692.2900,640.2200) .. controls
    (691.7400,674.7900) and (699.9500,686.2100) .. (646.7800,729.9900) .. controls
    (618.7100,753.1100) and (604.3400,759.5500) .. (603.0000,790.9300) --
    (547.2900,790.9300) -- cycle;
  \path[color=black,fill=c242424,rounded corners=0.0000cm] (522.2900,615.0000)
    rectangle (538.0040,817.5400);
  \path[fill=black,even odd rule] (537.9600,614.9800) -- (537.9600,817.6000) --
    (546.1300,809.4300) -- (546.1300,623.1500) -- (537.9600,614.9800) -- cycle;
\end{scope}
\begin{scope}[cm={{-1.0,0.0,0.0,1.0,(822.49,-205.0)}}]
  \path[color=black,draw=black,line cap=round,line width=6.000pt]
    (547.2900,790.9300) -- (548.7100,640.2200) -- (692.2900,640.2200) .. controls
    (691.7400,674.7900) and (699.9500,686.2100) .. (646.7800,729.9900) .. controls
    (618.7100,753.1100) and (604.3400,759.5500) .. (603.0000,790.9300) --
    (547.2900,790.9300) -- cycle;
  \path[color=black,fill=c242424,rounded corners=0.0000cm] (522.2900,615.0000)
    rectangle (538.0040,817.5400);
  \path[fill=black,even odd rule] (537.9600,614.9800) -- (537.9600,817.6000) --
    (546.1300,809.4300) -- (546.1300,623.1500) -- (537.9600,614.9800) -- cycle;
\end{scope}
\path[cm={{-1.0,0.0,0.0,1.0,(822.49,-410.0)}},color=black,draw=black,fill=black,opacity=0.250,line
  cap=round,line width=6.000pt] (547.2900,790.9300) -- (548.7100,640.2200) ..
  controls (548.7100,640.2200) and (573.5200,662.6400) .. (646.7800,729.9900) ..
  controls (618.7100,753.1100) and (604.3400,759.5500) .. (603.0000,790.9300) --
  (547.2900,790.9300) -- cycle;
\path[cm={{-1.0,0.0,0.0,1.0,(822.49,-205.0)}},color=black,draw=black,fill=black,opacity=0.250,line
  cap=round,line width=6.000pt] (547.2900,790.9300) -- (548.7100,640.2200) --
  (692.2900,640.2200) .. controls (691.7400,674.7900) and (699.9500,686.2100) ..
  (646.7800,729.9900) .. controls (618.7100,753.1100) and (604.3400,759.5500) ..
  (603.0000,790.9300) -- (547.2900,790.9300) -- cycle;
\path[cm={{-1.0,0.0,0.0,1.0,(822.49,0.0)}},color=black,draw=black,fill=black,opacity=0.250,line
  cap=round,line width=6.000pt] (547.2900,790.9300) -- (548.7100,640.2200) --
  (692.2900,640.2200) .. controls (691.7400,674.7900) and (699.9500,686.2100) ..
  (646.7800,729.9900) .. controls (618.7100,753.1100) and (604.3400,759.5500) ..
  (603.0000,790.9300) -- (547.2900,790.9300) -- cycle;
  \end{scope}
\end{scope}

\end{tikzpicture}
\end{document}
3

I suggest that you should use a suitable tool for each objective, in the case of TIKZ that specializes in nodes, texts, arrows, boxes, etc., not the creation of 2D drawings, although with the skill and the necessary time can be performed , but it will be like doing it with your hands tied, for that reason you should opt for a suitable tool with the same basic characteristics as free sodfware. So I suggest Inkscape, you can draw in a WYSIWYG environment, which as you see works quietly with the pdf files that are handled in both Tikz and Latex can get better results without compromising quality but perhaps sacrificing the file size. (not much I hope)

Testing results improving an image generated in tikz, retouched in inkscape, taking advantage of the compatibility of pdf formats, adding equations by importing a blank document with equations made in latex (Take as long as you want until you are satisfied with the result, in my case 37 minutes) to get this.

enter image description here

Of course all those images are vectors, you can zoom as much as you want without losing quality.

enter image description here

The cost is only the file size:

  1. Tikz_pdf_file: tikz2-5D.pdf -->7Kb.
  2. Inkscape SVG containing the imported pdf and edited --> 343Kb.
  3. Exported pdf_file: 2-5D.pdf -->25Kb. (that is the awesome thing).
  4. Inkscape SVG imported equation latex pdf and some aditional edition --> 373Kb.
  5. Exported pdf_file: 2-5Dred.pdf -->59Kb. (it's pretty good).

To check the transparency I used the package \background, The pdf file output size is: 103Kb.

% arara: pdflatex: {synctex: yes, action: nonstopmode}

\documentclass{scrreprt}
\usepackage{booktabs,caption}
\usepackage{graphicx}
\usepackage[
pages=some,
firstpage=true,
opacity=0.5,
placement=center,
angle=0,
hshift=20,
vshift=10
]{background}
\usepackage{subfigure}
\begin{document}
    \backgroundsetup{contents={\includegraphics[scale=.3]{2-5Dred.pdf}}}

    \begin{figure}[h!]
        \centering
        \subfigure[Obtained exportingTikz to pdf]{\includegraphics[width=.4\textwidth]{tikz2-5D.pdf}} \qquad
        \subfigure[Imported pdf from Tikz in Inkscape and improve effects, and export as pdf]{\includegraphics[width=.4\textwidth]{2-5D.pdf}} \par
        \subfigure[Adding more details and importing random equation generated as a result of the pdf of the empty latex page with normal equation codes, and then including text and a degradation of a dashed line box. Another advantage of using the PDF format is that transparency is available.]{\includegraphics[width=.7\textwidth]{2-5Dred.pdf}}
    \end{figure}

\end{document}

And the code for the equation pdf to import in Inkscape:

% arara: pdflatex: {synctex: yes, action: nonstopmode}

\documentclass{scrreprt}
\usepackage{amsmath,amsfonts,amssymb,latexsym,wasysym}  
\begin{document}
    \pagestyle{empty}
        $\varDelta\phi=\dfrac{4M}{d{s}}+(\dfrac{M}{d{s}})^{2}$
\end{document}

you can download the files here!

2
  • +1 Overall I agree with everything you are saying except that this way you lose control over the picture. If one has the TikZ code at hand, one can do all sorts of things like sloped annotations, animations etc. Such things are somewhat harder to achieve without the TikZ code. But yes, your results are definitely superior to my drawing. (And perhaps use my updated figure, but not the ducks of course, because it also has some sort of a shadow.)
    – user121799
    Apr 1, 2018 at 22:49
  • Thank you very much for those files also the result of your work is magnificent. In this case the problem is me because I am not talented enough to do drawings like you in a WYSIWYG software, I feel much more comfortable making drawings using coordinates. (
    – Paul Lara
    Apr 3, 2018 at 6:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .