|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
How to draw a growing line with tikz and animate?Dear all,
my name is Christian and I try to create a "growing line". A straight line should be drawn between (0,1) an (10,11) in ten steps, but unfortunately this code does not work out: \documentclass{beamer} \usepackage{tikz} \usepackage{animate} \begin{document} \begin{frame} \begin{animateinline}[autoplay, loop, palindrome, begin={\begin{tikzpicture}% }, end={\end{tikzpicture}}]{2} \multiframe{10}{itest=0+1, itast=1+1}{% \path[draw] (0,1)--(\itest,\itast);% } \end{animateinline} \end{frame} \end{document} What is wrong? Thanks in advance, Christian |
|
|
Re: How to draw a growing line with tikz and animate?Hi Christian I too fought with beamer and animations. It can work the way you want but once you start to mess with transparency I found problems. And then it will not work! The best way to circumvent this is to always use the externalization feature of tikz. This will also work with transparency! The way to do is to create a new tex file called "animcreator.tex"
%%% Contents "animcreator.tex" begins: \documentclass{article} \usepackage{tikz} \usetikzlibrary{external} \tikzexternalize{animcreator} % this has to be the name of the file, hence "animcreator" \tikzsetexternalprefix{figures/} \begin{document} \tikzset{external/force remake} \tikzset{external/figure name={line_}} \foreach \x in {0,...,10} { \begin{tikzpicture} \path[use as bounding box] (0,0) rectangle (10,11); \path[draw] (0,1) -- ++(\x,\x);% \end{tikzpicture} } \end{document} %%% End contents "animcreator.tex" Notice the line \path[use as bounding box]! This needs to encapsulate the largest frame of the animation. This ensures that all the pictures have the same size.
If you don't have it the animation will also increase in "raw"-picture size, and believe me, this can create havoc! :D The "animcreator.tex" will create 11 files in the "figures/" subfolder called "line_0.pdf" up to "line_10.pdf". And now you wish to use these as your animation!
So your real beamer file comes to look like this %%% Begin contents "beamer.tex" \documentclass{beamer} \usepackage{animate} \begin{document} \begin{frame} Hi \fbox{ \animategraphics[final,scale=.5]{2}% {figures/line_}{0}{10}% the frames lie in "figrues" subdirectory with beginning names "line_" } \end{frame} \end{document} %%% End contents "beamer.tex" Here you use the same package "animate" with the creation of animations from files! This can be utilized to a really great extent! Check out the "timeline" option for the package and you will see the advantages. This can ultimately decrease the file size if you have some frames than can be recycled! :D
The \fbox i always use the first time to see whether the "[use as bounding box]" fits snuggly! :D Hope this helps. Kind regards Nick Ps. if the externalization library doesn't work you should download the cvs version of pgf/TikZ. PPs. always remember "[use as bounding box]" i've cried my eyes out when i couldn't get it to fit, just because i forgot! :D
2009/10/17 Netzwerker <christian.woellenstein@...>
------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ pgf-users mailing list pgf-users@... https://lists.sourceforge.net/lists/listinfo/pgf-users |
|
|
Re: How to draw a growing line with tikz and animate?On Sat, Oct 17, 2009 at 3:21 PM, Nick Papior Andersen
<nickpapior@...> wrote: > Hi Christian > > I too fought with beamer and animations. It can work the way you want but > once you start to mess with transparency I found problems. And then it will > not work! > The best way to circumvent this is to always use the externalization feature > of tikz. This will also work with transparency! > The way to do is to create a new tex file called "animcreator.tex" > %%% Contents "animcreator.tex" begins: > \documentclass{article} > \usepackage{tikz} > \usetikzlibrary{external} > \tikzexternalize{animcreator} % this has to be the name of the file, hence > "animcreator" > \tikzsetexternalprefix{figures/} > \begin{document} > \tikzset{external/force remake} > \tikzset{external/figure name={line_}} > \foreach \x in {0,...,10} { > \begin{tikzpicture} > \path[use as bounding box] (0,0) rectangle (10,11); > \path[draw] (0,1) -- ++(\x,\x);% > \end{tikzpicture} > } > \end{document} > %%% End contents "animcreator.tex" > Notice the line \path[use as bounding box]! This needs to encapsulate the > largest frame of the animation. This ensures that all the pictures have the > same size. I also prefer this approach when working with animate.sty. An alternative to using the externalization facility of PGF is to use the preview package like this: %%% Contents "animcreator.tex" begins: \documentclass{article} \usepackage{tikz} \usepackage[active,tightpage]{preview} \PreviewEnvironment{tikzpicture} \begin{document} \foreach \x in {0,...,10} { \begin{tikzpicture} \path[use as bounding box] (0,0) rectangle (10,11); \path[draw] (0,1) -- ++(\x,\x);% \end{tikzpicture} } \end{document} %%% End contents "animcreator.tex" This will create a single PDF where each page of the PDF is one frame. To play the animation use: %%% Begin contents "beamer.tex" \documentclass{beamer} \usepackage{animate} \begin{document} \begin{frame} Hi \fbox{ \animategraphics[final,scale=.5]{2}{animcreator}{}{} } \end{frame} \end{document} %%% End contents "beamer.tex" You can find some more details in this example: http://www.texample.net/tikz/examples/animated-set-intersection/ - Kjell Magne Fauske ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ pgf-users mailing list pgf-users@... https://lists.sourceforge.net/lists/listinfo/pgf-users |
|
|
Re: How to draw a growing line with tikz and animate?Dear all,
I'd like to thank for all your hints, which helped me a lot. The bounding box was the key to solve my problem. Now everything works fine. Greetings, Christian ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ pgf-users mailing list pgf-users@... https://lists.sourceforge.net/lists/listinfo/pgf-users |
| Free embeddable forum powered by Nabble | Forum Help |