放大镜头

放大镜头

我正在尝试绘制一个中间带有摄像头的镜头,类似于 iPhone 中的镜头,然后我想将其缩放。这是我目前能做到的。

每当我尝试最小化镜头以适应管道尺寸时,我都会收到尺寸过大的错误。

\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{decorations.markings,decorations.pathreplacing,calc}
\makeatletter
\usetikzlibrary{spy, backgrounds}
\usetikzlibrary{calc,fadings,decorations.text}
\tikzfading[name=fade inside, inner color=transparent!90, outer color=transparent!40]

\tikzset{every pipe/.code={%
  \pgfmathloop
  \ifnum\pgfmathcounter>20
  \else
    \pgfmathsetmacro\i{\pgfmathcounter}%
    \pgfmathsetmacro\j{80-\pgfmathcounter*3}%
    \tikzset{preaction/.expanded={line width=(\pipewidth)*(1-\i*\i/500),
        draw=black!50!white!\j!white}}%
  \repeatpgfmathloop
},
every flange/.style 2 args={insert path={
  let \p1=(#1), \p2=(#2),\n1={atan2(\y2-\y1, \x2-\x1)} in
    [shift={(\p1)}, rotate=\n1, pipe width={(\pipewidth)*4/3}, every pipe] 
      (0.01,0) -- (0.2,0)
}},
flanges/.style={postaction={%
  /utils/exec={
    \@for\pos:=#1\do{%
      \tikzset{decoration/.expanded={markings,
        mark=at position \pos\space with {
          \noexpand\path [pipe width=\pipewidth*4/3, every pipe] (0.01,0) -- (0.2,0);
    }}}}}, 
  decorate}},
pipe width/.code=\pgfmathsetlengthmacro\pipewidth{#1},
pipes/.style={
  every pipe,
  postaction={decoration={show path construction,
    lineto code={
      \path [every flange={\tikzinputsegmentfirst}{\tikzinputsegmentlast}];
      \path [every flange={\tikzinputsegmentlast}{\tikzinputsegmentfirst}];
    },
    curveto code={
      \path [every flange={\tikzinputsegmentfirst}{\tikzinputsegmentsupporta}];
      \path [every flange={\tikzinputsegmentlast}{\tikzinputsegmentsupportb}];
    }
}, decorate}},
pipe/.style={
  every pipe,
  flanges={0, 1}
}}
\begin{document}
\begin{tikzpicture}[line join=round,spy using outlines={circle, magnification=15, size=1.95cm, connect spies, transform shape}]
\path [pipe width=0.5cm, pipes] (-2,0) -- (-2,-5) arc (180:270:2)--(3,-7);
\path [pipe width=0.06cm, pipes] (-1.9,0) -- (-1.9,-5) arc (180:270:1.9)--(3,-6.9);
\coordinate (zoomLoc) at (1,-1.5);
\spy [black] on (-1.9,-3) in node [left] at (zoomLoc);

  \coordinate (baseSupportLunette) at (0,-4);
  \coordinate (coinSupportCameras) at  -- ($(baseSupportLunette)+(-3,1.75)$);
  \coordinate (moteurTilt) at (-1.75,0);

 \coordinate (baseSupportLunette) at (0,-4);
  \coordinate (coinSupportCameras) at  -- ($(baseSupportLunette)+(-3,1.75)$);
  \coordinate (moteurTilt) at (-1.75,0);
\coordinate (O) at  (-1.9,-3);
\def\x{2}

  % lens
%  \filldraw[black!85] (0,0) circle (1.75cm);
  \draw [darkgray] (O) circle ({0.01/\x});
  \shade [ball color=white,path fading=fade inside] (O) circle ({0.00975/\x});
  \draw [gray] (O) circle (0.025/\x);
  
 % \draw[] (O) circle (0.06);
 % \draw [darkgray] (O) circle (0.075);
  \shade [ball color=white,path fading=fade inside] (O) circle ({0.06225/\x});
  %\draw [darkgray,thick] (O) circle (0.125);
 % \draw [thick] (O) circle (0.135);
  \begin{scope}
    \clip (O) circle ({0.175/\x});
    \foreach \i in {0.8,...,1} \shade [ball color=white!95!blue, blend mode=hard light, opacity=1] (135:{0.13*(0.8-\i}) circle ({0.13*\i/\x});
    \shade [ball color=white!95!blue, shading angle=0, blend mode=hard light, opacity=1] (O) circle (0.13/\x);
    \draw [solid,black] (O) circle (0.01/\x);
  \end{scope}
\end{tikzpicture}
\end{document}

答案1

更新答案:

这个怎么样?

我不知道这\x是做什么用的,所以我就忽略了它。遮阳球现在不再比小管宽了。这是正确的吗?

碳

平均能量损失

\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{decorations.markings,decorations.pathreplacing,calc}
\makeatletter
\usetikzlibrary{spy, backgrounds}
\usetikzlibrary{calc,fadings,decorations.text}
\tikzfading[name=fade inside, inner color=transparent!90, outer color=transparent!40]

\tikzset{every pipe/.code={%
  \pgfmathloop
  \ifnum\pgfmathcounter>20
  \else
    \pgfmathsetmacro\i{\pgfmathcounter}%
    \pgfmathsetmacro\j{80-\pgfmathcounter*3}%
    \tikzset{preaction/.expanded={line width=(\pipewidth)*(1-\i*\i/500),
        draw=black!50!white!\j!white}}%
  \repeatpgfmathloop
},
every flange/.style 2 args={insert path={
  let \p1=(#1), \p2=(#2),\n1={atan2(\y2-\y1, \x2-\x1)} in
    [shift={(\p1)}, rotate=\n1, pipe width={(\pipewidth)*4/3}, every pipe] 
      (0.01,0) -- (0.2,0)
}},
flanges/.style={postaction={%
  /utils/exec={
    \@for\pos:=#1\do{%
      \tikzset{decoration/.expanded={markings,
        mark=at position \pos\space with {
          \noexpand\path [pipe width=\pipewidth*4/3, every pipe] (0.01,0) -- (0.2,0);
    }}}}}, 
  decorate}},
pipe width/.code=\pgfmathsetlengthmacro\pipewidth{#1},
pipes/.style={
  every pipe,
  postaction={decoration={show path construction,
    lineto code={
      \path [every flange={\tikzinputsegmentfirst}{\tikzinputsegmentlast}];
      \path [every flange={\tikzinputsegmentlast}{\tikzinputsegmentfirst}];
    },
    curveto code={
      \path [every flange={\tikzinputsegmentfirst}{\tikzinputsegmentsupporta}];
      \path [every flange={\tikzinputsegmentlast}{\tikzinputsegmentsupportb}];
    }
}, decorate}},
pipe/.style={
  every pipe,
  flanges={0, 1}
}}
\begin{document}
\begin{tikzpicture}[line join=round,spy using outlines={circle, magnification=3.5, size=1.95cm, connect spies, transform shape}]
\path [pipe width=0.5cm, pipes] (-2,0) -- (-2,-5) arc (180:270:2)--(3,-7);
\path [pipe width=0.06cm, pipes] (-1.9,0) -- (-1.9,-5) arc (180:270:1.9)--(3,-6.9);
\coordinate (zoomLoc) at (1.5,-1.5);
\spy [black] on (-2,-3) in node [left] at (zoomLoc);

  \coordinate (baseSupportLunette) at (0,-4);
  \coordinate (coinSupportCameras) at  -- ($(baseSupportLunette)+(-3,1.75)$);
  \coordinate (moteurTilt) at (-1.75,0);

 \coordinate (baseSupportLunette) at (0,-4);
  \coordinate (coinSupportCameras) at  -- ($(baseSupportLunette)+(-3,1.75)$);
  \coordinate (moteurTilt) at (-1.75,0);
\coordinate (O) at  (-1.9,-3);
\def\x{1}

  % lens
%  \filldraw[black!85] (0,0) circle (1.75cm);
  \draw [violet] (O) circle ({0.01/\x});
  \shade [ball color=green,path fading=fade inside] (O) circle ({0.012/\x});
  \draw [blue] (O) circle (0.013/\x);
  
 % \draw[] (O) circle (0.06);
 % \draw [darkblue] (O) circle (0.075);
  \shade [ball color=red,path fading=fade inside] (O) circle ({0.014/\x});
  %\draw [darkblue,thick] (O) circle (0.125);
 % \draw [thick] (O) circle (0.135);
  \begin{scope}
    \clip (O) circle ({0.175/\x});
    \foreach \i in {0.8,...,1} \shade [ball color=white!95!blue, blend mode=hard light, opacity=1] (135:{0.13*(0.8-\i}) circle ({0.13*\i/\x});
    \shade [ball color=white!95!blue, shading angle=0, blend mode=hard light, opacity=1] (O) circle (0.03/\x);
    \draw [solid,black] (O) circle (0.01/\x);
  \end{scope}
\end{tikzpicture}
\end{document}

原始答案:

这是一张图片,我将放大倍数调低至magnification=3.5,稍微向左移动spy on\spy [black] on (-2,-3)...然后设置x1\def\x{1}管道现在适合两个圆圈。

的功能或目的是什么\x?它的目的是控制什么?

飞涨

平均能量损失

\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{decorations.markings,decorations.pathreplacing,calc}
\makeatletter
\usetikzlibrary{spy, backgrounds}
\usetikzlibrary{calc,fadings,decorations.text}
\tikzfading[name=fade inside, inner color=transparent!90, outer color=transparent!40]

\tikzset{every pipe/.code={%
  \pgfmathloop
  \ifnum\pgfmathcounter>20
  \else
    \pgfmathsetmacro\i{\pgfmathcounter}%
    \pgfmathsetmacro\j{80-\pgfmathcounter*3}%
    \tikzset{preaction/.expanded={line width=(\pipewidth)*(1-\i*\i/500),
        draw=black!50!white!\j!white}}%
  \repeatpgfmathloop
},
every flange/.style 2 args={insert path={
  let \p1=(#1), \p2=(#2),\n1={atan2(\y2-\y1, \x2-\x1)} in
    [shift={(\p1)}, rotate=\n1, pipe width={(\pipewidth)*4/3}, every pipe] 
      (0.01,0) -- (0.2,0)
}},
flanges/.style={postaction={%
  /utils/exec={
    \@for\pos:=#1\do{%
      \tikzset{decoration/.expanded={markings,
        mark=at position \pos\space with {
          \noexpand\path [pipe width=\pipewidth*4/3, every pipe] (0.01,0) -- (0.2,0);
    }}}}}, 
  decorate}},
pipe width/.code=\pgfmathsetlengthmacro\pipewidth{#1},
pipes/.style={
  every pipe,
  postaction={decoration={show path construction,
    lineto code={
      \path [every flange={\tikzinputsegmentfirst}{\tikzinputsegmentlast}];
      \path [every flange={\tikzinputsegmentlast}{\tikzinputsegmentfirst}];
    },
    curveto code={
      \path [every flange={\tikzinputsegmentfirst}{\tikzinputsegmentsupporta}];
      \path [every flange={\tikzinputsegmentlast}{\tikzinputsegmentsupportb}];
    }
}, decorate}},
pipe/.style={
  every pipe,
  flanges={0, 1}
}}
\begin{document}
\begin{tikzpicture}[line join=round,spy using outlines={circle, magnification=3.5, size=1.95cm, connect spies, transform shape}]
\path [pipe width=0.5cm, pipes] (-2,0) -- (-2,-5) arc (180:270:2)--(3,-7);
\path [pipe width=0.06cm, pipes] (-1.9,0) -- (-1.9,-5) arc (180:270:1.9)--(3,-6.9);
\coordinate (zoomLoc) at (1.5,-1.5);
\spy [black] on (-2,-3) in node [left] at (zoomLoc);

  \coordinate (baseSupportLunette) at (0,-4);
  \coordinate (coinSupportCameras) at  -- ($(baseSupportLunette)+(-3,1.75)$);
  \coordinate (moteurTilt) at (-1.75,0);

 \coordinate (baseSupportLunette) at (0,-4);
  \coordinate (coinSupportCameras) at  -- ($(baseSupportLunette)+(-3,1.75)$);
  \coordinate (moteurTilt) at (-1.75,0);
\coordinate (O) at  (-1.9,-3);
\def\x{1}

  % lens
%  \filldraw[black!85] (0,0) circle (1.75cm);
  \draw [violet] (O) circle ({0.01/\x});
  \shade [ball color=white,path fading=fade inside] (O) circle ({0.00975/\x});
  \draw [blue] (O) circle (0.025/\x);
  
 % \draw[] (O) circle (0.06);
 % \draw [darkblue] (O) circle (0.075);
  \shade [ball color=white,path fading=fade inside] (O) circle ({0.06225/\x});
  %\draw [darkblue,thick] (O) circle (0.125);
 % \draw [thick] (O) circle (0.135);
  \begin{scope}
    \clip (O) circle ({0.175/\x});
    \foreach \i in {0.8,...,1} \shade [ball color=white!95!blue, blend mode=hard light, opacity=1] (135:{0.13*(0.8-\i}) circle ({0.13*\i/\x});
    \shade [ball color=white!95!blue, shading angle=0, blend mode=hard light, opacity=1] (O) circle (0.13/\x);
    \draw [solid,black] (O) circle (0.01/\x);
  \end{scope}
\end{tikzpicture}
\end{document}

相关内容