Document layout and layers/Presentations/Animation

Unofficial ConTeXt Wiki mirror

Last modified: 2025-01-18

< Presentations | Presentation effects | Raw steps module | Macros for presentation with steps | JavaScript>

Introduction

If you want to give some dynamics to your documents, there are essentially two possibilities to do so:

The first alternative can be hardcoded, achieved with either some trickery (\dorecurse may sometimes help you) or with support of modules such as Raw steps module.

This page will mostly deal with JavaScript animations.

An example

Suppose you have a presentation and you want the content of a slide to be gradually shown on the screen like in the next example:

Slide 1

If a chicken and a half lays an egg and a half in a day and a half, how many eggs can one chicken lay in one day?

Slide 2

If a chicken and a half lays an egg and a half in a day and a half, how many eggs can one chicken lay in one day?
- What a stupid question! ONE, of course.

Slide 3

If a chicken and a half lays an egg and a half in a day and a half, how many eggs can one chicken lay in one day?
- What a stupid question! ONE, of course.
- Wrong! I'll give you one more try: how many eggs can one chicken lay in a day and a half?

Slide 4

If a chicken and a half lays an egg and a half in a day and a half, how many eggs can one chicken lay in one day?
- What a stupid question! ONE, of course.
- Wrong! I'll give you one more try: how many eggs can one chicken lay in a day and a half?
- Wait a minute ... one chicken can lay 2/3 eggs in one day, doesn't it?

The difference in how the two mentioned method would deal with it:

Comparison

It all depends on your needs which of the two mentioned possibilities would suit you most. Here are some advantages and disadvanteges of both methods listed.

  PROS CONS
Multiple pages
  • almost any PDF viewer can read it
  • you can quickly browse forwards/backwards with PgDown/PgUp or mouse
  • may result in a huge amount of pages (and huge size as well)
  • only static - you have to move it forward/backward manually
JavaScript
  • complex animations possible
  • good support in ConTeXt
  • not supported by every PDF viewer (only Acrobat >= 6)
  • even in Acrobat not always backward-compatible (may change in the next version)
  • some programming practice needed
  • buttons to trigger the animation have to be predefined precisely (you can't simply jump from one frame to another unless you programmed it that way)

How to make movies?

Even if you were leaping for joy once you heard about the animations, I have to disappoint you right away: no matter how hard you try, it's not very likely that you'll ever achive much more than one, maybe some frames per second. So won't really be able to watch movies this way.

However, there's another possibility to use your nice metapost figures to make animations, pdf2swf. See http://melusine.eu.org/syracuse/metapost/animations/ and http://www.quiss.org/swftools/examples.html for examples.

Preparing the figures with Metapost/Metafun

JavaScript Animations

Animations in plain TeX

Animations in a pdfTeX-generated PDF

Examples

Using the animation module

Simple example

\usemodule[animation]
\setupinteraction[state=start]

\starttext

\startanimation
{\externalfigure[dummy]A}
{\externalfigure[dummy]B}
{\externalfigure[dummy]C}
{\externalfigure[dummy]D}
\stopanimation

\stoptext

Add captions

\usemodule[animation]
\setupinteraction[state=start]

\definepairedbox[animationtext][location=top,align=middle,width=\textwidth]

\starttext

\startanimation
{\placeanimationtext{The letter a}{\externalfigure[dummy]}}
{\placeanimationtext{The letter b}{\externalfigure[dummy]}}
{\placeanimationtext{The letter c}{\externalfigure[dummy]}}
{\placeanimationtext{The letter d}{\externalfigure[dummy]}}
\stopanimation

\stoptext

Example with formulae

\usemodule[animation]

\setuppapersize[S6][S6]

\setupinteraction[state=start]

\definepairedbox[animationtext][location=top,align=middle,width=\textwidth]

\starttext

\startanimation
{\placeanimationtext{Sine norm, and}{\startformula \int_{0}^{2\pi}\sin^2(x)dx = \stopformula}}
{\placeanimationtext{Cosine norm}{\startformula\int_{0}^{2\pi}\cos^2(x)dx = \stopformula}}
{\placeanimationtext{are equal}{\startformula = \pi. \stopformula}}
\stopanimation

\stoptext

Animating Text

TODO: presentations with pre-61

Making animations with MetaPost MetaFun

Making animations with external tools

Samples

Documentation


TODO: Here are a lot of empty sections, and a bit more order won't hurt (See: To-Do List)