摄影的 TikZ 图表(光圈和对焦环)

摄影的 TikZ 图表(光圈和对焦环)

我正在准备一门关于摄影的课程,我想添加一些示例来说明镜头如何根据光圈环渲染焦点。因此,我想创建一个显示下图的 TikZ 图形。

镜片

具体来说,我只对下面显示的数字感兴趣。所以我想要一个可以修改的 TikZ 图形,看起来像这样:

                              ft  15   10   7     5
                              m   5    3     2   1.5
------------------------------------+----+-+-<>-+-+---+--+-----
                                    16   8 4    4 8      16
16     11    8      5.6     4    2.8     2   1.4

您能就如何创建它提供任何建议吗?

答案1

尽管您没有展示任何内容,但您在这里尝试了一个解决方案:

\documentclass{article}

\usepackage{tikz}
\usepackage{ifthen}

\usepackage{xcolor}
\usepackage[sfdefault,condensed]{roboto}

% #1: x coordinate of bottom middle, #2: y coordinate of bottom middle
\newcommand{\dofcentermark}[2]{
        \draw[fill=white] (#1,#2) -- (#1-0.125,#2+0.28) -- (#1,#2+0.56) -- (#1+0.125,#2+0.28) -- cycle;
    }

% #1: x coordinate of dof mark, #2: y coordinate of dof mark, #3 dof mark text
\newcommand{\dofrangemark}[3]{
        \ifthenelse{\equal{#3}{}}
            {\node (DOF_range)  at (#1,#2) {\phantom{1}};}
            {\node (DOF_range)  at (#1,#2) {#3};}
        \draw[-] (DOF_range) -- ++(0,0.45);
    }

% #1: move whole display in x direction, #2: move window content in x direction
\newcommand{\distancenodes}[2][0]{
        \node (ft) at (-2.8+#1,2) {ft};
        \node (m) at (-2.8+#1,1.5) {m};
        \begin{scope}
            % clipping window
            \clip[draw](-2.5+#1,1.2) rectangle (2.5+#1,2.4);
            % ft
            \node (15ft) at (-2.15+#1+#2,2) {15};
            \node (10ft) at (-1.5+#1+#2,2) {10};
            \node (7ft) at (-0.2+#1+#2,2) {7};
            \node (5ft) at (1.7+#1+#2,2) {5};
            % m
            \node (5m) at (-2.3+#1+#2,1.5) {5};
            \node (3m) at (-1.45+#1+#2,1.5) {3};
            \node (2m) at (0+#1+#2,1.5) {2};
            \node (1.5m) at (1.8+#1+#2,1.5) {1.5};
        \end{scope}
        \dofrangemark{-2+#1}{0.75}{16}
        \dofrangemark{-1.3+#1}{0.75}{}
        \dofrangemark{-0.85+#1}{0.75}{8}
        \dofrangemark{-0.58+#1}{0.75}{}
        \dofrangemark{-0.4+#1}{0.75}{4}
        \dofcentermark{#1}{0.6}
        \dofrangemark{0.4+#1}{0.75}{4}
        \dofrangemark{0.58+#1}{0.75}{}
        \dofrangemark{0.85+#1}{0.75}{8}
        \dofrangemark{1.3+#1}{0.75}{}
        \dofrangemark{2+#1}{0.75}{16}
    }

% #1: x shift of aperture ring
\newcommand{\aperturenodes}[1][0]{
        \node (f16) at  (0+#1,0) {16};
        \node (f11) at  (1+#1,0) {11};
        \node (f8) at   (2+#1,0) {8};
        \node (f5.6) at (3+#1,0) {5.6};
        \node (f4) at   (4+#1,0) {4};
        \node (f2.8) at (5+#1,0) {2.8};
        \node (f2) at   (6+#1,0) {2};
        \node (f1.4) at (7+#1,0) {1.4}; 
    }

\begin{document}
    \begin{tikzpicture}
        %\draw[fill] (0,-1) rectangle (14,3.5);     % if you uncomment these two parts it will become white on black background
        \begin{scope}%[color=white]                 % if you uncomment these two parts it will become white on black background
            \distancenodes[9]{0}
            \aperturenodes[2]
        \end{scope}
    \end{tikzpicture}
\end{document}

编辑:添加更好的字体

在此处输入图片描述

编辑:现在实现了正确计算 DOF 窗口编号的间距,并可轻松选择 f 档和对焦距离以创建图像 编辑:现在实现了正确计算 DOF 窗口编号的间距,并可轻松选择 f 档和对焦距离以创建图像

\documentclass{article}

\usepackage{tikz}
\usepackage{ifthen}
\usepackage{xfp}

\usepackage{xcolor}
\usepackage[sfdefault,condensed]{roboto}

\definecolor{almost-black}{gray}{0.1}
\definecolor{dark-gray}{gray}{0.2}
\definecolor{middle-gray}{gray}{0.5}
\definecolor{light-gray}{gray}{0.7}

% #1: x coordinate of bottom middle, #2: y coordinate of bottom middle
\newcommand{\dofcentermark}[2]{
    \draw[fill=white] (#1,#2) -- (#1-0.125,#2+0.28) -- (#1,#2+0.56) -- (#1+0.125,#2+0.28) -- cycle;
}

\newcommand{\dofrangedisplaytext}{}
% #1: x coordinate of dof mark, #2: y coordinate of dof mark, #3 dof mark text
\newcommand{\dofrangemark}[3]{
    \ifthenelse{\equal{#3}{}}
    {\renewcommand{\dofrangedisplaytext}{\phantom{1}}}
    {\renewcommand{\dofrangedisplaytext}{#3}}
    \node (DOF_range)  at (#1,#2) {\dofrangedisplaytext};
    \draw[-] (DOF_range) -- ++(0,0.45);
}

\newcommand{\meterinfeet}[1]{\fpeval{3.28*#1}}
\newcommand{\feetinmeter}[1]{\fpeval{0.3048*#1}}

\newcommand{\dofdistancescalingfactor}{8.01}

% #1: x-offset, #2: y-offset
\newcommand{\dofdistancenodeinfty}[2]{
    \node (infty) at (#1+\fpeval{\dofdistancescalingfactor/999}, #2) {$\infty$};
}

% #1: x-offset, #2: y-offset, #3: dof-distance in meter
\newcommand{\dofdistancenodemeter}[3]{
    \node (#3m) at (#1+\fpeval{\dofdistancescalingfactor/#3}, #2) {#3};
}

% #1: x-offset, #2: y-offset, #3: dof-distance in feet
\newcommand{\dofdistancenodefeet}[3]{
    \node[color=yellow] (#3m) at (#1+\fpeval{\dofdistancescalingfactor/\feetinmeter{#3}}, #2) {#3};
}

\newcommand{\dofwindowxoffset}{}
\newcommand{\dofwindowyoffsetmeter}{1.5}
\newcommand{\dofwindowyoffsetfeet}{1.9}
\newcommand{\dofwindowyoffsetmarks}{0.85}
\newcommand{\fstopringyoffset}{0.3}

% #1: move whole display in x direction, #2: move window content to x m
\newcommand{\distancenodes}[2][0]{
    
    % meter and feet text
    \node[color=yellow] (ft) at (-2.8+#1, \dofwindowyoffsetfeet) {ft};
    \node (m) at (-2.8+#1, \dofwindowyoffsetmeter) {m};
    
    \renewcommand{\dofwindowxoffset}{#1+#2-4}
    \begin{scope}
        % clipping window
        \clip[draw](-2.5+#1,1.3) rectangle (2.5+#1,2.15);
        
        % ft labels
        \dofdistancenodefeet{\dofwindowxoffset}{\dofwindowyoffsetfeet}{60}
        \dofdistancenodefeet{\dofwindowxoffset}{\dofwindowyoffsetfeet}{25}
        \dofdistancenodefeet{\dofwindowxoffset}{\dofwindowyoffsetfeet}{15}
        \dofdistancenodefeet{\dofwindowxoffset}{\dofwindowyoffsetfeet}{10}
        \dofdistancenodefeet{\dofwindowxoffset}{\dofwindowyoffsetfeet}{7}
        \dofdistancenodefeet{\dofwindowxoffset}{\dofwindowyoffsetfeet}{5}           
        \dofdistancenodefeet{\dofwindowxoffset}{\dofwindowyoffsetfeet}{4}
        \dofdistancenodefeet{\dofwindowxoffset}{\dofwindowyoffsetfeet}{3}           \dofdistancenodefeet{\dofwindowxoffset}{\dofwindowyoffsetfeet}{2.5} 
        
        % infinity label
        \dofdistancenodeinfty{\dofwindowxoffset}{\dofwindowyoffsetmeter}        
        
        % meter labels
        \dofdistancenodemeter{\dofwindowxoffset}{\dofwindowyoffsetmeter}{15}
        \dofdistancenodemeter{\dofwindowxoffset}{\dofwindowyoffsetmeter}{7}
        \dofdistancenodemeter{\dofwindowxoffset}{\dofwindowyoffsetmeter}{5}
        \dofdistancenodemeter{\dofwindowxoffset}{\dofwindowyoffsetmeter}{3}
        \dofdistancenodemeter{\dofwindowxoffset}{\dofwindowyoffsetmeter}{2}
        \dofdistancenodemeter{\dofwindowxoffset}{\dofwindowyoffsetmeter}{1.5}
        \dofdistancenodemeter{\dofwindowxoffset}{\dofwindowyoffsetmeter}{1.2}
        \dofdistancenodemeter{\dofwindowxoffset}{\dofwindowyoffsetmeter}{1}
        \dofdistancenodemeter{\dofwindowxoffset}{\dofwindowyoffsetmeter}{0.8}
        
        % shadow
        \draw[draw=none,rectangle, left color=black, right color=dark-gray, anchor=south west, opacity=0.5] (-2.5+#1,1.3) rectangle (-2.4+#1,2.15);
        \draw[draw=none,rectangle, right color=black, left color=dark-gray, anchor=south west, opacity=0.5] (2.5+#1,1.3) rectangle (2.4+#1,2.15);       
        
        \draw[color=light-gray] (-2.5+#1,1.3) rectangle (2.5+#1,2.15);
        
    \end{scope}
    
    % top border
    \draw[fill, color=light-gray] (0,2.15) rectangle ++(#1+3.5,0.15);
    \draw[fill, color=almost-black] (0,2.15) rectangle ++(#1+3.5,0.03); 
    
    % rifling
    \foreach \x in {0,0.28,...,20}
        \draw[fill, color=middle-gray] (0+\x,2.35) rectangle ++(0.1,0.3);
        
    \dofrangemark{-\dofwindowxposition{\dofmaxfm{16}{2}}+#1}{\dofwindowyoffsetmarks}{16}
    \dofrangemark{-\dofwindowxposition{\dofmaxfm{11}{2}}+#1}{\dofwindowyoffsetmarks}{}
    \dofrangemark{-\dofwindowxposition{\dofmaxfm{8}{2}}+#1}{\dofwindowyoffsetmarks}{8}
    \dofrangemark{-\dofwindowxposition{\dofmaxfm{5.6}{2}}+#1}{\dofwindowyoffsetmarks}{}
    \dofrangemark{-\dofwindowxposition{\dofmaxfm{4}{2}}+#1}{\dofwindowyoffsetmarks}{4}
    \dofcentermark{#1}{\dofwindowyoffsetmarks-0.15}
    \dofrangemark{-\dofwindowxposition{\dofminfm{4}{2}}+#1}{\dofwindowyoffsetmarks}{4}
    \dofrangemark{-\dofwindowxposition{\dofminfm{5.6}{2}}+#1}{\dofwindowyoffsetmarks}{}
    \dofrangemark{-\dofwindowxposition{\dofminfm{8}{2}}+#1}{\dofwindowyoffsetmarks}{8}
    \dofrangemark{-\dofwindowxposition{\dofminfm{11}{2}}+#1}{\dofwindowyoffsetmarks}{}
    \dofrangemark{-\dofwindowxposition{\dofminfm{16}{2}}+#1}{\dofwindowyoffsetmarks}{16}
}

% #1: f-stop, #2: focal distance
\newcommand{\dofmaxfm}[2]{\fpeval{round(#2*\focallength^2/(\focallength^2-#1*\circleofconfusion*(#2-\focallength)),2)}} 
% #1: f-stop, #2: focal distance
\newcommand{\dofminfm}[2]{\fpeval{round(#2*\focallength^2/(\focallength^2+#1*\circleofconfusion*(#2-\focallength)),2)}}

% #1: x shift of aperture ring
\newcommand{\aperturenodes}[1][0]{
    % right rifling
    \foreach \x in {0,0.28,...,2.5}
        \draw[fill, color=middle-gray] (#1+\x,\fstopringyoffset-0.28) rectangle ++(0.1,0.58);
    
    % left rifling
    \foreach \x in {0,-0.28,...,-6}
        \draw[fill, color=middle-gray] (#1-9+\x,\fstopringyoffset-0.28) rectangle ++(0.1,0.58);      
    
    % top line
    \draw[fill, color=almost-black] (0,\fstopringyoffset+0.3) rectangle ++(#1+3.5,0.03);
    
    % aperture text
    \node (f16)  at (#1-8,\fstopringyoffset) {16};
    \node (f11)  at (#1-7,\fstopringyoffset) {11};
    \node (f8)   at (#1-6,\fstopringyoffset) {8};
    \node (f5.6) at (#1-5,\fstopringyoffset) {5.6};
    \node (f4)   at (#1-4,\fstopringyoffset) {4};
    \node (f2.8) at (#1-3,\fstopringyoffset) {2.8};
    \node (f2)   at (#1-2,\fstopringyoffset) {2};
    \node (f1.4) at (#1-1,\fstopringyoffset) {1.4};
    
    % bottom line
    \draw[fill, color=almost-black] (0,\fstopringyoffset-0.28) rectangle ++(#1+3.5,0.03);
    
}

\newcommand{\dofwindowxposition}[1]{
    \fpeval{\dofdistancescalingfactor/2-\dofdistancescalingfactor/#1}
}
\newcommand{\clipfill}[2]{
    \draw[draw=none,color=#1, fill] #2;
    \clip #2;   
}

% #2: f-stop, #3: distance in m
\newcommand{\dofscalefm}[3][8]{
    \begin{tikzpicture}
        \begin{scope}[color=white]
            \clipfill{dark-gray}{(0,0) rectangle ++(#1+3.5,2.34)}
            \distancenodes[#1]{\dofwindowxposition{#3}}
            \aperturenodes[#1+\fpeval{round(ln(#2^2)/ln(2))}]
        \end{scope}
    \end{tikzpicture}
}

\newcommand{\circleofconfusion}{0.000035}
\newcommand{\focallength}{0.05}

\begin{document}
    \verb|\dofscalefm[4.5]{1.4}{2}|
    
    \dofscalefm[4.5]{1.4}{2}
    \\

    \verb|\dofscalefm{2}{\feetinmeter{15}}|

    \dofscalefm{2}{\feetinmeter{15}}
    \\
    
    \verb|\dofscalefm{11}{\feetinmeter{3}}|

    \dofscalefm{11}{\feetinmeter{3}}
    \\
    
    \verb|\dofscalefm[4]{11}{1} |

    \dofscalefm[4]{11}{1}   
\end{document}

在此处输入图片描述

相关内容