如何在 TikZ 中创建阴影效果

如何在 TikZ 中创建阴影效果

我想创建自己的beamer theme,并且我已经获得了它的粗略代码。

\documentclass[serif]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{tikz,blindtext,enumerate,charter}
\usetikzlibrary{fadings,positioning,calc}
\newcommand{\changefont}[3]{\fontfamily{#1}\fontseries{#2}\fontshape{#3}\selectfont}
\definecolor{blau}{RGB}{0,191,255}
%\definecolor{blau}{RGB}{226, 245, 13}
\definecolor{ora}{RGB}{253,111,1}
\setbeamertemplate{navigation symbols}{}
\begin{document}
    \begin{frame}
        \begin{tikzpicture}[remember picture,overlay]
        \fill[inner color=blau] (current page.south west) rectangle (current page.north east);
            \node[opacity=.6] at ([xshift=.05cm,yshift=1.03cm]$(current page.north west)!.5!(current page.south east)$) {\Huge\sc Die Überschrift};
        \node[red] at ([yshift=1cm]$(current page.north west)!.5!(current page.south east)$) {\Huge\sc Die Überschrift};
        \node[ora] at ([yshift=-.5cm]$(current page.north west)!.5!(current page.south east)$) {\changefont{lmr}{m}{it}Der Autor};
        \end{tikzpicture}
    \end{frame}
    \begin{frame}
        \begin{tikzpicture}[overlay,remember picture]
            \fill[path fading=north,fading transform={yshift=-.5cm},fading angle=225,blau] (current page.north west) rectangle (current page.south east);
                \node[yshift=.2cm,above left] at (current page.south east) {\changefont{lmr}{m}{n}Zeichnen mit Ti\emph{\color{blau}k}Z};
                \node[yshift=.15cm,xslant=.6,xshift=-1.75cm,yscale=-1,opacity=.4] at (current page.south east) {\changefont{lmr}{m}{n}Zeichnen mit Ti\emph{\color{blau}k}Z};
                \fill[opacity=.6,black] ([xshift=2.1cm]current page.north west) -- ([xshift=2.1cm,yshift=-1.5cm]current page.north west) -- ([xshift=2.6cm,yshift=-1.2cm]current page.north west) -- ([xshift=3.1cm,yshift=-1.5cm]current page.north west) -- ([xshift=3.1cm]current page.north west);
            \fill[red] ([xshift=2cm]current page.north west) -- ([xshift=2cm,yshift=-1.5cm]current page.north west) -- ([xshift=2.5cm,yshift=-1.2cm]current page.north west) -- ([xshift=3cm,yshift=-1.5cm]current page.north west) -- ([xshift=3cm]current page.north west);
            \node[white,inner sep=0pt] (a) at ([xshift=2.5cm,yshift=-.5cm]current page.north west) {\changefont{pzc}{b}{n}Thema};
            \node[white,below=.2mm of a] {\changefont{lmtt}{m}{b}1};
            \draw[red,thick,yshift=.1cm] (-1,3) -- (7.7,3) node[near end,above,xshift=1cm,red] {\changefont{put}{m}{n}Der Titel};
%           \node[below left,opacity=.3,rotate=-20,xshift=1cm,yshift=-.5cm] at (current page.north east) {\includegraphics[scale=.2]{shot}};
        \end{tikzpicture}
        \vspace{-2cm}\parbox{.7\textwidth}{\color{black!85}\footnotesize\blindtext[1]}
    \end{frame}
    \begin{frame}
            \begin{tikzpicture}[overlay,remember picture]
                \fill[path fading=north,fading transform={yshift=-.5cm},fading angle=225,blau] (current page.north west) rectangle (current page.south east);
                    \node[yshift=.26cm,above left] at (current page.south east) {\changefont{lmr}{m}{n}Die Präsentation};
%                   {Das Arbeiten mit \color{blau}\sc\LaTeX};
                    \node[yshift=.15cm,xslant=.6,xshift=-1.6cm,yscale=-1,opacity=.4] at (current page.south east)  {\changefont{lmr}{m}{n}Die Präsentation};
%                   {Das Arbeiten mit \color{blau}\sc\LaTeX};
                    \fill[opacity=.6,black] ([xshift=2.1cm]current page.north west) -- ([xshift=2.1cm,yshift=-1.5cm]current page.north west) -- ([xshift=2.6cm,yshift=-1.2cm]current page.north west) -- ([xshift=3.1cm,yshift=-1.5cm]current page.north west) -- ([xshift=3.1cm]current page.north west);
                \fill[red] ([xshift=2cm]current page.north west) -- ([xshift=2cm,yshift=-1.5cm]current page.north west) -- ([xshift=2.5cm,yshift=-1.2cm]current page.north west) -- ([xshift=3cm,yshift=-1.5cm]current page.north west) -- ([xshift=3cm]current page.north west);
                \node[white,inner sep=0pt] (a) at ([xshift=2.5cm,yshift=-.5cm]current page.north west) {\changefont{pzc}{b}{n}Thema};
                \node[white,below=.2mm of a] {\changefont{lmtt}{m}{b}2};
                %\node[below left,opacity=.3,rotate=-20,xshift=1cm,yshift=-.5cm] at (current page.north east) {\includegraphics[scale=.2]{shot}};
            \end{tikzpicture}
        \vspace{-2cm}\parbox{.7\textwidth}{
            \begin{enumerate}[\tikz{\fill[white]circle(.13);\fill[red]circle(.1);}]
                \item \color{black!85}Hallo,
                \item Welt!
            \end{enumerate}
            }
    \end{frame}
\end{document}

输出如下:

截屏

截屏

截屏

我的问题是:我怎样才能实现这一目标

  • “阴影”效果(例如带有 TikZ 的图画;下面不透明度较低的相同文本)会自动调整至上面的文本(这是否意味着不再xshift=…需要)?

我只知道一些可以将其转变为“主题”的命令,但我对使用该类没有经验beamer,我只知道基础知识。

答案1

如果有特殊的比例变换(如yscale=-1或 ) ,节点相对定位会更加棘手xslant=...。要更明确地看到这一点,只需给出节点“Zeichnen mit TiZ”(这有点矛盾,因为 TiZ 代表“TiZ ist kein Zeichenprogramm)名称TWZ,并相对于它放置一个节点

\node[below=0pt of ZWT.south,opacity=.4] {\changefont{lmr}{m}{n}Zeichnen mit Ti\emph{\color{blau}k}Z};

在此处输入图片描述

好吧,有点远,但这仅仅是由于两个都节点。减去它们得到

\node[below=-2*\pgfkeysvalueof{/pgf/inner ysep} of ZWT.south,opacity=.4] {\changefont{lmr}{m}{n}Zeichnen mit Ti\emph{\color{blau}k}Z};

在此处输入图片描述

接下来,打开xslant=.6,yscale=-1,

\node[xslant=.6,yscale=-1,below=-2*\pgfkeysvalueof{/pgf/inner ysep} of ZWT.south,opacity=.4] {\changefont{lmr}{m}{n}Zeichnen mit Ti\emph{\color{blau}k}Z};

在此处输入图片描述

疯狂,现在节点是多于节点TWZ。为什么?因为距离已经经过了变换。所以我们必须用

\node[xslant=.6,yscale=-1,xshift=-1.8*\pgfkeysvalueof{/pgf/inner
            ysep},below=2.2*\pgfkeysvalueof{/pgf/inner ysep} of ZWT.south,opacity=.4] {\changefont{lmr}{m}{n}Zeichnen mit Ti\emph{\color{blau}k}Z};

在此处输入图片描述

我没有使用,below=2*\pgfkeysvalueof{/pgf/inner ysep}因为我希望有一个小间隙。 的前因子类似xshift,理论上应该是2*0.6=1.2,但节点倾斜,我们希望它更靠左。

因此,底线是,人们可以理解所有这些转变的来源,但最终人们仍然需要手动调整一些东西。人们可以通过使用锚点来部分避免这种情况,但它们在转换下也会改变其含义,因此我不确定这是否会给我们带来很大帮助。

\documentclass[serif]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{tikz,blindtext,enumerate,charter}
\usetikzlibrary{fadings,positioning,calc}
\newcommand{\changefont}[3]{\fontfamily{#1}\fontseries{#2}\fontshape{#3}\selectfont}
\definecolor{blau}{RGB}{0,191,255}
%\definecolor{blau}{RGB}{226, 245, 13}
\definecolor{ora}{RGB}{253,111,1}
\setbeamertemplate{navigation symbols}{}
\begin{document}
    \begin{frame}
        \begin{tikzpicture}[remember picture,overlay]
        \fill[inner color=blau] (current page.south west) rectangle (current page.north east);
            \node[opacity=.6] at ([xshift=.05cm,yshift=1.03cm]$(current page.north west)!.5!(current page.south east)$) {\Huge\sc Die Überschrift};
        \node[red] at ([yshift=1cm]$(current page.north west)!.5!(current page.south east)$) {\Huge\sc Die Überschrift};
        \node[ora] at ([yshift=-.5cm]$(current page.north west)!.5!(current page.south east)$) {\changefont{lmr}{m}{it}Der Autor};
        \end{tikzpicture}
    \end{frame}
    \begin{frame}
        \begin{tikzpicture}[overlay,remember picture]
            \fill[path fading=north,fading transform={yshift=-.5cm},fading angle=225,blau] (current page.north west) rectangle (current page.south east);
                \node[yshift=.2cm,above left] at (current page.south east) (ZWT){\changefont{lmr}{m}{n}Zeichnen mit Ti\emph{\color{blau}k}Z};
%                \node[xslant=.6,yscale=-1,below=-2*\pgfkeysvalueof{/pgf/inner ysep} of ZWT.south,opacity=.4] {\changefont{lmr}{m}{n}Zeichnen mit Ti\emph{\color{blau}k}Z};
%                \node[below=0pt of ZWT.south,xslant=.6,yscale=-1,opacity=.4] {\changefont{lmr}{m}{n}Zeichnen mit Ti\emph{\color{blau}k}Z};
                 \node[xslant=.6,yscale=-1,xshift=-1.8*\pgfkeysvalueof{/pgf/inner
                ysep},below=2.2*\pgfkeysvalueof{/pgf/inner ysep} of ZWT.south,opacity=.4] {\changefont{lmr}{m}{n}Zeichnen mit Ti\emph{\color{blau}k}Z};
                \fill[opacity=.6,black] ([xshift=2.1cm]current page.north west) -- ([xshift=2.1cm,yshift=-1.5cm]current page.north west) -- ([xshift=2.6cm,yshift=-1.2cm]current page.north west) -- ([xshift=3.1cm,yshift=-1.5cm]current page.north west) -- ([xshift=3.1cm]current page.north west);
            \fill[red] ([xshift=2cm]current page.north west) -- ([xshift=2cm,yshift=-1.5cm]current page.north west) -- ([xshift=2.5cm,yshift=-1.2cm]current page.north west) -- ([xshift=3cm,yshift=-1.5cm]current page.north west) -- ([xshift=3cm]current page.north west);
            \node[white,inner sep=0pt] (a) at ([xshift=2.5cm,yshift=-.5cm]current page.north west) {\changefont{pzc}{b}{n}Thema};
            \node[white,below=.2mm of a] {\changefont{lmtt}{m}{b}1};
            \draw[red,thick,yshift=.1cm] (-1,3) -- (7.7,3) node[near end,above,xshift=1cm,red] {\changefont{put}{m}{n}Der Titel};
%           \node[below left,opacity=.3,rotate=-20,xshift=1cm,yshift=-.5cm] at (current page.north east) {\includegraphics[scale=.2]{shot}};
        \end{tikzpicture}
        \vspace{-2cm}\parbox{.7\textwidth}{\color{black!85}\footnotesize\blindtext[1]}
    \end{frame}
    \begin{frame}
            \begin{tikzpicture}[overlay,remember picture]
                \fill[path fading=north,fading transform={yshift=-.5cm},fading angle=225,blau] (current page.north west) rectangle (current page.south east);
                    \node[yshift=.26cm,above left] at (current page.south east) {\changefont{lmr}{m}{n}Die Präsentation};
%                   {Das Arbeiten mit \color{blau}\sc\LaTeX};
                    \node[yshift=.15cm,xslant=.6,xshift=-1.6cm,yscale=-1,opacity=.4] at (current page.south east)  {\changefont{lmr}{m}{n}Die Präsentation};
%                   {Das Arbeiten mit \color{blau}\sc\LaTeX};
                    \fill[opacity=.6,black] ([xshift=2.1cm]current page.north west) -- ([xshift=2.1cm,yshift=-1.5cm]current page.north west) -- ([xshift=2.6cm,yshift=-1.2cm]current page.north west) -- ([xshift=3.1cm,yshift=-1.5cm]current page.north west) -- ([xshift=3.1cm]current page.north west);
                \fill[red] ([xshift=2cm]current page.north west) -- ([xshift=2cm,yshift=-1.5cm]current page.north west) -- ([xshift=2.5cm,yshift=-1.2cm]current page.north west) -- ([xshift=3cm,yshift=-1.5cm]current page.north west) -- ([xshift=3cm]current page.north west);
                \node[white,inner sep=0pt] (a) at ([xshift=2.5cm,yshift=-.5cm]current page.north west) {\changefont{pzc}{b}{n}Thema};
                \node[white,below=.2mm of a] {\changefont{lmtt}{m}{b}2};
                %\node[below left,opacity=.3,rotate=-20,xshift=1cm,yshift=-.5cm] at (current page.north east) {\includegraphics[scale=.2]{shot}};
            \end{tikzpicture}
        \vspace{-2cm}\parbox{.7\textwidth}{
            \begin{enumerate}[\tikz{\fill[white]circle(.13);\fill[red]circle(.1);}]
                \item \color{black!85}Hallo,
                \item Welt!
            \end{enumerate}
            }
    \end{frame}
\end{document}

相关内容