ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Animations in ConTeXt
@ 2005-05-20 16:00 Richard Rascher-Friesenhausen
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Rascher-Friesenhausen @ 2005-05-20 16:00 UTC (permalink / raw)


Hello list,

i have recently found the webpage 
      http://www.tug.org/texshowcase/
with a lot of astonishing TeX typesettings. Most of all, because i was looking 
for this, i was impressed by the animation possibilities of pdftex. See 
'LorenzAttractor.tex' in the 'Dynamic documents' section. It is a LaTeX 
implementation using a lot of JavaScript. Is something like this possible in 
ConTeXt?

I'm aware  of fieldstacks and step by step presentations. But i would like to 
generate 'pdf-movies', especially for mathematical animations using MetaPost 
as an graphical engine.

There exists also a 'solution' for plain TeX:   
                        http://www.fi.muni.cz/~xholecek/animations/
But i had no success in generating the pdf-files from the sources. No 
animation was shown. 

So again. Is it possible to write something like the above animation packages 
in ConTeXt (as a module)?

Thanks in advance
    richard rascher-friesenhausen


-- 

==============================================================================
Richard Rascher-Friesenhausen                
MeVis -- Centrum fuer Medizinische Diagnosesysteme und Visualisierung GmbH
Universitaetsallee 29
D-28359 Bremen

email: richard@mevis.de
www  : http://www.mevis.de/
fon  : +49 - 421 - 218 7707 (mevis)
fax  : +49 - 421 - 218 4236 (mevis)
==============================================================================

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Animations in ConTeXt
@ 2005-05-22 10:19 Richard Hirsch
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Hirsch @ 2005-05-22 10:19 UTC (permalink / raw)


Richard Rascher-Friesenhausen asked
> So again. Is it possible to write something like the above animation
packages 
> in ConTeXt (as a module)?

If Acrobat can display them, ConTeXt can generate them.

Here is a simple example. 

\setupoutput      [pdf]
\setupcolors      [state=start]
\setupinteraction [state=start]
\setuppapersize   [S6][S6]

%% this is just code to get something to animate
\startMPinclusions
  picture thearrow, thestar;

  drawarrow (origin--up) scaled 10mm
    withpen pencircle scaled 3pt
    withcolor .9 red;
  setbounds currentpicture to (fullcircle scaled 22mm);

  thearrow:= currentpicture scaled 5;
  currentpicture:= nullpicture;

  for angle=0 step 72 until 359:
    draw thearrow rotated angle;
  endfor

  thestar:= currentpicture;
  currentpicture:= nullpicture
\stopMPinclusions

\setupMPvariables [drawstar] [rotation=0]
\startuniqueMPgraphic{drawstar}{rotation}
  draw thestar rotated \MPvar{rotation};
\stopuniqueMPgraphic


%% now we define some symbols (the frames of the animated sequence)
\def\definestarsymbol#1{%
  \definesymbol [star #1] [\uniqueMPgraphic{drawstar}{rotation=#1}]}

\definestarsymbol{0}
\definestarsymbol{6}
\definestarsymbol{12}
\definestarsymbol{18}
\definestarsymbol{24}
\definestarsymbol{30}
\definestarsymbol{36}
\definestarsymbol{42}
\definestarsymbol{48}
\definestarsymbol{54}
\definestarsymbol{60}
\definestarsymbol{66}

%% the frames are put into a fieldstack
\definefieldstack [vortex]
  [star 0,  star 6,  star 12, star 18, star 24, star 30, 
   star 36, star 42, star 48, star 54, star 60, star 66]

%% and this is the JavaScrip code that displays the frames one by one
\startJSpreamble MyField used later
var current = 1;
var delay   = 200;              % 200 milliseconds
var timer;
var running = false;            % animation currently not running

function Advance_Angle ( ) {
  this.getField("vortex:"+current).value = "Off";
  if (++current > 12)    % number of frames
    { current = 1; }    % loop through frames
  this.getField("vortex:"+current).value = "On";
}
\stopJSpreamble

%% we want to control the starting and stopping of the animation
\startJScode Rotate_Star uses MyField
if (running) { 
  try { app.clearInterval(timer); } catch(except) {};
  running = false;
}
else { 
  timer = app.setInterval("Advance_Angle()",delay); 
  running = true;
}
\stopJScode


\starttext
  \placefigure [here] [fig:animation]
  {A simple \MetaFun\ animation,
  click \goto {here} [JS(Rotate_Star)] to start (or stop)}
  {\fieldstack [vortex]}
\stoptext

Of course you would want to put the symbol definitions and the
definition of the fieldstack into a loop. I tried 
%% \newcount\angle
%% \angle=0%\zerocount
%% \dorecurse{12} {%
%%    \number\angle:\qquad
%%    \definestarsymbol{\the\angle}
%%    \symbol[star \number\angle]\par
%%    \advance\angle by 6}
and did get the single symbols. I wasn't successful however in putting
the symbol list of the fieldstack definition into a loop. Perhaps the
ConTeXt gurus can help.

Best regards,

  Richard

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-05-22 10:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-20 16:00 Animations in ConTeXt Richard Rascher-Friesenhausen
2005-05-22 10:19 Richard Hirsch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).