5

I have to do a schematic featuring a camera lens so I tried my best to make the drawing look like an actual lens. I've been told several times that it looks a lot more like a speaker than a camera lens.

In order to improve this drawing I thought that a good starting point would be to put some reflections on what is supposed to be the lens glass. But I have no idea how to proceed in Tikz. Most transparency and shade effects that I tried make it look even worse...

Here is a MWE of what I tried

\documentclass[tikz]{standalone}
\usetikzlibrary{calc}
\usetikzlibrary{fadings}
\usetikzlibrary{decorations.text}
\tikzfading[name=fade inside, inner color=transparent!90, outer color=transparent!40]

\begin{document}
    \begin{tikzpicture} 
        \coordinate (baseSupportLunette) at (0,-4);
        \coordinate (coinSupportCameras) at  -- ($(baseSupportLunette)+(-3,1.75)$);
        \coordinate (moteurTilt) at (-1.75,0);

        \draw[very thick,gray,dashed] (baseSupportLunette) -- (0,3);

        % lens 
        \filldraw[black!85] (0,0) circle (1.75cm);
        \draw[darkgray] (0,0) circle (0.2);
        \shade [ball color=white,path fading=fade inside] (0,0) circle (0.195);
        \draw[gray] (0,0) circle (0.5);
        \draw[] (0,0) circle (0.6);
        \draw[darkgray] (0,0) circle (0.75);
        \shade [ball color=white,path fading=fade inside] (0,0) circle (1.245);
        \draw[darkgray,thick] (0,0) circle (1.25);
        \draw[thick] (0,0) circle (1.35);       

        % lens support
        \draw[line width=1mm,darkgray] (0,-2.25) -- (baseSupportLunette); 

        % structure
        \draw[darkgray,line width=1mm,rounded corners] (1.75,0)%
        -- (2.3,0)%
        -- (2.3,-2.25)%
        -- (coinSupportCameras)%
        -- (-3,0) -- (moteurTilt); 

        % lens border
        \draw[very thick] (0,0) circle (1.75); 

        % top rotation arrow
        \draw[very thick,stealth-stealth] (-0.125,2.625) arc [start angle=100, end angle=440,x radius=0.75cm, y radius=0.125cm];   

        % side rotation arrow
        \draw[very thick,stealth-stealth] (-2.25,0.125) arc [start angle=10, end angle=350,x radius=0.125cm, y radius=0.75cm];

        % lens label
        \path [postaction={decorate,decoration%
        ={raise=0pt,text along path, reverse path=true,%
        text align/align=center,%
        text align/left indent={4.5553093477052cm},%
        text color=lightgray,%
        text=|\sffamily\scriptsize|CAMERA LENS}}]%
         (0,0) circle (1.45cm);         
    \end{tikzpicture}
\end{document}
1
  • 3
    TikZ is not the right tool for lighting effects ....
    – cfr
    Jun 17, 2017 at 1:19

1 Answer 1

12

TikZ is not the tool for lighting effects. Not unless you wish to draw them pixel by pixel, which is always an option if you don't need something scalable, I suppose. The package just isn't designed for it.

Mark Wibrow will come up with something which reflects prismatic light in real time, thus proving me conclusively wrong. But TikZ still isn't a good choice for this, since other tools ... well, there are tools which have actually heard about light ....

Caveat emptor ...

lighting effect

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,fadings,decorations.text}
\tikzfading[name=fade inside, inner color=transparent!90, outer color=transparent!40]

\begin{document}
\begin{tikzpicture}
  \coordinate (baseSupportLunette) at (0,-4);
  \coordinate (coinSupportCameras) at  -- ($(baseSupportLunette)+(-3,1.75)$);
  \coordinate (moteurTilt) at (-1.75,0);

  \draw[very thick,gray,dashed] (baseSupportLunette) -- (0,3);

  % lens
  \filldraw[black!85] (0,0) circle (1.75cm);
  \draw [darkgray] (0,0) circle (0.2);
  \shade [ball color=white,path fading=fade inside] (0,0) circle (0.195);
  \draw [gray] (0,0) circle (0.5);
  \draw[] (0,0) circle (0.6);
  \draw [darkgray] (0,0) circle (0.75);
  \shade [ball color=white,path fading=fade inside] (0,0) circle (1.245);
  \draw [darkgray,thick] (0,0) circle (1.25);
  \draw [thick] (0,0) circle (1.35);
  \begin{scope}
    \clip (0,0) circle (1.75);
    \foreach \i in {8,...,10,11} \shade [ball color=white!85!blue, blend mode=hard light, opacity=1] (135:{1.3*(10-\i}) circle ({0.13*\i});
    \shade [ball color=white!85!blue, shading angle=0, blend mode=hard light, opacity=1] (0,0) circle (1.3);
  \end{scope}
  % lens support
  \draw[line width=1mm,darkgray] (0,-2.25) -- (baseSupportLunette);

  % structure
  \draw[darkgray,line width=1mm,rounded corners] (1.75,0)%
  -- (2.3,0)%
  -- (2.3,-2.25)%
  -- (coinSupportCameras)%
  -- (-3,0) -- (moteurTilt);

  % lens border
  \draw[very thick] (0,0) circle (1.75);

  % top rotation arrow
  \draw[very thick,stealth-stealth] (-0.125,2.625) arc [start angle=100, end angle=440,x radius=0.75cm, y radius=0.125cm];

  % side rotation arrow
  \draw[very thick,stealth-stealth] (-2.25,0.125) arc [start angle=10, end angle=350,x radius=0.125cm, y radius=0.75cm];

  % lens label
  \path [postaction={decorate,decoration%
    ={raise=0pt,text along path, reverse path=true,%
      text align/align=center,%
      text align/left indent={4.5553093477052cm},%
      text color=lightgray,%
      text=|\sffamily\scriptsize|CAMERA LENS}}]%
  (0,0) circle (1.45cm);
\end{tikzpicture}
\end{document}

EDIT

Here's the effect of adding the shadings library and

% Mark Wibrow's suggestion
    \shade [shading=color wheel, path fading=fade inside] circle (1.3);

as Mark Wibrow suggested.

with colour wheel shading

Or, using

    \shade [shading=color wheel black center, path fading=fade inside] circle (1.3);

with a slightly different colour wheel shading

With a radius of only 1, as suggested, it looks strange to me.

suggested radius

But perhaps I'm just mistaken.

EDIT EDIT

Complete code for coloured versions:

% ateb: https://tex.stackexchange.com/a/375369/ addaswyd o gwestiwn jrojasqu: https://tex.stackexchange.com/q/375362/
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{fadings,decorations.text,shadings}
\tikzfading[name=fade inside, inner color=transparent!90, outer color=transparent!40]

\begin{document}
\begin{tikzpicture}
  \coordinate (baseSupportLunette) at (0,-4);
  \coordinate (moteurTilt) at (-1.75,0);

  % lens
  \filldraw[black!85] (0,0) circle (1.75cm);
  \draw [darkgray] (0,0) circle (0.2);
  \shade [ball color=white,path fading=fade inside] (0,0) circle (0.195);
  \draw [gray] (0,0) circle (0.5);
  \draw[] (0,0) circle (0.6);
  \draw [darkgray] (0,0) circle (0.75);
  \shade [ball color=white,path fading=fade inside] (0,0) circle (1.245);
  \draw [darkgray,thick] (0,0) circle (1.25);
  \draw [thick] (0,0) circle (1.35);
  \begin{scope}
    \clip (0,0) circle (1.75);
    % Mark Wibrow's suggestion
    \shade [shading=color wheel, path fading=fade inside] circle (1);
    \foreach \i in {8,...,10,11} \shade [ball color=white!85!blue, blend mode=hard light, opacity=1] (135:{1.3*(10-\i}) circle ({0.13*\i});
    \shade [ball color=white!85!blue, shading angle=0, blend mode=hard light, opacity=1] (0,0) circle (1.3);
  \end{scope}

  % lens border
  \draw[very thick] (0,0) circle (1.75);

  % lens label
  \path [postaction={decorate,decoration%
    ={raise=0pt,text along path, reverse path=true,%
      text align/align=center,%
      text align/left indent={4.5553093477052cm},%
      text color=lightgray,%
      text=|\sffamily\scriptsize|CAMERA LENS}}]%
  (0,0) circle (1.45cm);
\end{tikzpicture}
\begin{tikzpicture}
  \coordinate (baseSupportLunette) at (0,-4);
  \coordinate (moteurTilt) at (-1.75,0);

  % lens
  \filldraw[black!85] (0,0) circle (1.75cm);
  \draw [darkgray] (0,0) circle (0.2);
  \shade [ball color=white,path fading=fade inside] (0,0) circle (0.195);
  \draw [gray] (0,0) circle (0.5);
  \draw[] (0,0) circle (0.6);
  \draw [darkgray] (0,0) circle (0.75);
  \shade [ball color=white,path fading=fade inside] (0,0) circle (1.245);
  \draw [darkgray,thick] (0,0) circle (1.25);
  \draw [thick] (0,0) circle (1.35);
  \begin{scope}
    \clip (0,0) circle (1.75);
    % Mark Wibrow's suggestion
    \shade [shading=color wheel, path fading=fade inside] circle (1.3);
    \foreach \i in {8,...,10,11} \shade [ball color=white!85!blue, blend mode=hard light, opacity=1] (135:{1.3*(10-\i}) circle ({0.13*\i});
    \shade [ball color=white!85!blue, shading angle=0, blend mode=hard light, opacity=1] (0,0) circle (1.3);
  \end{scope}

  % lens border
  \draw[very thick] (0,0) circle (1.75);

  % lens label
  \path [postaction={decorate,decoration%
    ={raise=0pt,text along path, reverse path=true,%
      text align/align=center,%
      text align/left indent={4.5553093477052cm},%
      text color=lightgray,%
      text=|\sffamily\scriptsize|CAMERA LENS}}]%
  (0,0) circle (1.45cm);
\end{tikzpicture}
\begin{tikzpicture}
  \coordinate (baseSupportLunette) at (0,-4);
  \coordinate (moteurTilt) at (-1.75,0);

  % lens
  \filldraw[black!85] (0,0) circle (1.75cm);
  \draw [darkgray] (0,0) circle (0.2);
  \shade [ball color=white,path fading=fade inside] (0,0) circle (0.195);
  \draw [gray] (0,0) circle (0.5);
  \draw[] (0,0) circle (0.6);
  \draw [darkgray] (0,0) circle (0.75);
  \shade [ball color=white,path fading=fade inside] (0,0) circle (1.245);
  \draw [darkgray,thick] (0,0) circle (1.25);
  \draw [thick] (0,0) circle (1.35);
  \begin{scope}
    \clip (0,0) circle (1.75);
    % Mark Wibrow's suggestion
    \shade [shading=color wheel black center, path fading=fade inside] circle (1.3);
    \foreach \i in {8,...,10,11} \shade [ball color=white!85!blue, blend mode=hard light, opacity=1] (135:{1.3*(10-\i}) circle ({0.13*\i});
    \shade [ball color=white!85!blue, shading angle=0, blend mode=hard light, opacity=1] (0,0) circle (1.3);
  \end{scope}

  % lens border
  \draw[very thick] (0,0) circle (1.75);

  % lens label
  \path [postaction={decorate,decoration%
    ={raise=0pt,text along path, reverse path=true,%
      text align/align=center,%
      text align/left indent={4.5553093477052cm},%
      text color=lightgray,%
      text=|\sffamily\scriptsize|CAMERA LENS}}]%
  (0,0) circle (1.45cm);
\end{tikzpicture}
\end{document}
12
  • 3
    At least it doesn't look like a speaker ....
    – cfr
    Jun 17, 2017 at 2:03
  • Late night TeXing :) Jun 17, 2017 at 4:21
  • 1
    @Dr.ManuelKuehner Late night procrastination ... :(.
    – cfr
    Jun 17, 2017 at 22:58
  • Well -- your unproductive work is still impressive :). Jun 18, 2017 at 10:32
  • 3
    @cfr not "prismatic light in real time", but how about using the shadings library and adding something like \shade [shading=color wheel, path fading=fade inside] circle (1); before the first \shade [ball color=... ;) Jun 19, 2017 at 6:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.