通过TiKZ样式定义实现Beamer动画(非overlay命令)

beamer 2019-10-06 20:21  浏览 :1999
在使用Beamer宏包制作Slides(演示文稿)时,可以使用overlay命令控制不同页面中的需要显示内容,当连续播放这些页面时,就可以生成动画效果。 但类似`\\visible<>`、`\\only<>`这样的overlay命令一方面对目标明暗效果控制方式单一,另一方面是无法保持所有绘制对象在所有页面有效,因此,无法进行很好的坐标计算等操作。 今天在[Mindmap tikzpicture in beamer (reveal step by step)](https://tex.stackexchange.com/questions/55806/mindmap-tikzpicture-in-beamer-reveal-step-by-step#55849 "Mindmap tikzpicture in beamer (reveal step by step)")看到一个用自定义TiKZ的`visible on=<...>`样式实现的动画方式,在此与大家分享: ```tex \\documentclass{ctexbeamer} \\usepackage{tikz} \\usetikzlibrary{mindmap} \\begin{document} % https://tex.stackexchange.com/questions/55806/mindmap-tikzpicture-in-beamer-reveal-step-by-step#55849 % Keys to support piece-wise uncovering of elements in TikZ pictures: % \\node[visible on=<2->](foo){Foo} % \\node[visible on=<{2,4}>](bar){Bar} % put braces around comma expressions % % Internally works by setting opacity=0 when invisible, which has the % adavantage (compared to \\node<2->(foo){Foo} that the node is always there, hence % always consumes space plus that coordinate (foo) is always available. % % The actual command that implements the invisibility can be overriden % by altering the style invisible. For instance \\tikzsset{invisible/.style={opacity=0.2}} % would dim the "invisible" parts. Alternatively, the color might be set to white, if the % output driver does not support transparencies (e.g., PS) % \\tikzset{ invisible/.style={opacity=0.0,text opacity=0.0}, visible on/.style={alt={#1{}{invisible}}}, alt/.code args={<#1>#2#3}{% \\alt<#1>{\\pgfkeysalso{#2}}{\\pgfkeysalso{#3}} }, } \\begin{frame} \\frametitle{思维导图} \\begin{tikzpicture}[mindmap, concept color=gray!50, font=\\sffamily, text=white] \\tikzstyle{level 1 concept}+=[font=\\sffamily, sibling angle=90,level distance = 30mm] \\node[concept,scale=0.7] {开设课程} [clockwise from=135] child[concept color=orange, visible on=<2->]{ node[concept,scale=0.7]{C语言程序设计} } child[concept color=orange, visible on=<3->]{ node[concept,scale=0.7]{高等数学} } child[concept color=orange, visible on=<4->]{ node[concept,scale=0.7]{大学物理} } child[concept color=orange, visible on=<5->]{ node[concept,scale=0.7]{线性代数} }; \\end{tikzpicture} \\end{frame} \\end{document} ``` 生成的效果如下:
如果需要控制显示明暗效果,可以通过改变参数实现,如: ```tex \\tikzset{ invisible/.style={opacity=0.2,text opacity=0.8}, visible on/.style={alt={#1{}{invisible}}}, alt/.code args={<#1>#2#3}{% \\alt<#1>{\\pgfkeysalso{#2}}{\\pgfkeysalso{#3}} }, } ``` 生成的效果如下:
利用这一设置,可以使用类似`visible on=<{1,3-4,8}>`或` visible on={<1,3-4,8>}`这样的方式为绘制对象指定显示的页面,从而更为灵活的控制Beamer动画的制作。 Happy TiKZing!
发布评论
登录后方可评论!点击登录
全部评论 (0)
暂无评论, 快来抢沙发!