summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/generic/xypic/movie.cls
blob: 7c3f29d73f6f340679028d6b1ef35b764a84a70b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
%% $Id: movie.cls,v 3.4 1997/05/18 01:14:25 krisrose Exp $ -*-latex-*-
%%
%% ``LaTeX Movie'' document class for DVI animations.
%% Copyright (c) 1994-1997	Kristoffer H. Rose  <krisrose@brics.dk>
%%
%% This file is part of the Xy-pic package for graphs and diagrams in TeX.
%% Copyright (c) 1991-1997	Kristoffer H. Rose  <krisrose@brics.dk>
%%
%% The Xy-pic package is free software; you can redistribute it and/or modify
%% it under the terms of the GNU General Public License as published by the
%% Free Software Foundation; either version 2 of the License, or (at your
%% option) any later version.
%%
%% The Xy-pic package is distributed in the hope that it will be useful, but
%% WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
%% or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
%% for more details.
%%
%% You should have received a copy of the GNU General Public License along
%% with this package; if not, write to the Free Software Foundation, Inc.,
%% 675 Mass Ave, Cambridge, MA 02139, USA.
%%
\ifx\xyloaded\undefined \input xy \fi

\NeedsTeXFormat{LaTeX2e}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Version.

\def\next$#1: #2 #3${#2}
\edef\next{\noexpand\ProvidesClass{movie}%
  [\next$Date: 1997/05/18 01:14:25 $
   Movies in LaTeX v.\next$Revision: 3.4 $.]}\next

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Options.

% nocaption  (omit caption at lower left; default)
% caption    (include caption)
\newif\ifm@caption
\DeclareOption{nocaption}{\m@captionfalse}
\DeclareOption{caption}{\m@captiontrue}

% nocount  (omit count at lower left; default)
% count    (include count)
\newif\ifm@count
\DeclareOption{nocount}{\m@countfalse}
\DeclareOption{count}{\m@counttrue}

% notime  (omit elapsed time in "seconds"; default)
% time    (include elapsed time)
\newif\ifm@time
\DeclareOption{notime}{\m@timefalse}
\DeclareOption{time}{\m@timetrue}

% loop  (make the animation loop; default)
% once  (don't loop)
\def\loop@@{-ns2}
\DeclareOption{loop}{\def\loop@@{-ns2}}
\DeclareOption{once}{\def\loop@@{-once}}

% Paper size (ignored since result is never printed).
\DeclareOption{a4paper}{}
\DeclareOption{a5paper}{}
\DeclareOption{b5paper}{}
\DeclareOption{letterpaper}{}
\DeclareOption{legalpaper}{}
\DeclareOption{executivepaper}{}
\DeclareOption{landscape}{}

%\vsize=9in \voffset=0in
%\hsize=7in \hoffset=0in % safe? :)

\newdimen\textheight \textheight=\vsize
\newdimen\textwidth  \textwidth=\hsize

% Font size.
\renewcommand\normalsize{\fontsize{10}{12}\selectfont}
\DeclareOption{10pt}{\renewcommand\normalsize{\fontsize{10}{12}\selectfont}}
\DeclareOption{11pt}{\renewcommand\normalsize{\fontsize{11}{13}\selectfont}}
\DeclareOption{12pt}{\renewcommand\normalsize{\fontsize{12}{14}\selectfont}}

% Driver (passed on to packages).
\DeclareOption{cmactex}{\OptionNotUsed}
\DeclareOption{dvips}{\OptionNotUsed}
\DeclareOption{dvitops}{\OptionNotUsed}
\DeclareOption{emtex}{\OptionNotUsed}
\DeclareOption{ln}{\OptionNotUsed}
\DeclareOption{oztex}{\OptionNotUsed}
\DeclareOption{textures}{\OptionNotUsed}
\DeclareOption{xdvi}{\OptionNotUsed}

% ...remaining options are numeric assignments...
\def\m@keys{}
\def\add@m@keys#1{\expandafter\def\expandafter\m@keys\expandafter{\m@keys,#1}}
\DeclareOption*{\expandafter\add@m@keys\expandafter{\CurrentOption}}

\ProcessOptions*

\LoadClass{article}
\pagestyle{empty}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Dependencies.

\RequirePackage{keyval}         % key=value pair support
\input xy                       % Xy-pic kernel (not package to prevent clash)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Parameters (set via options or the setup).

% pixel=<dimen>  (makes \pixels{<number>} a valid <dimen>; default: 1in/300)
% dpi=<number>   (dots per inch ~ pixel=1in/number)
\newdimen\m@pixel \m@pixel=0.0033333333in
\define@key{movie}{pixel}{\m@pixel=#1\relax}
\define@key{movie}{dpi}{\m@pixel=1in \divide \m@pixel by #1\relax}

% height=<dimen>
% width=<dimen>
\newdimen\m@height \m@height=2in
\newdimen\m@width  \m@width=2in
\define@key{movie}{height}{\m@height=#1\relax}
\define@key{movie}{width}{\m@width=#1\relax}

% tick=<fraction>  (set the duration of each frame to <fraction> seconds)
% fps=<number>     (frames per second ~ tick=1/number)
\newdimen\m@tick \m@tick=0.083333333pt
\define@key{movie}{tick}{\m@tick=#1pt\relax}
\define@key{movie}{fps}{\m@tick=1pt \divide \m@tick by #1\relax}

\def\next#1{\setkeys{movie}{#1}}
\expandafter\next\expandafter{\m@keys}
\let\m@keys=\undefined

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Setting parameters explicitly...

\def\MovieSetup#1{\setkeys{movie}{#1}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Internals.

\def\m@caption{}

\countdef\m@scene=1             % count1 = scene#
\countdef\m@frame=2             % count2 = frame# (in scene)

\font\fiverm=cmr5               % safe small font

\newdimen\m@total \m@total=0pt  % total elapsed time

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% User accessible progress macros:

\def\theFrame{0}
\def\theScene{0}

\def\theF{0}
\def\theFr{1}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% User command: \scene [<fraction>] {...}
%
% Produce scene of <fraction> seconds (default: 1.0) with each frame produced
% by ... centered in vertical mode.

\newif\iflastframe@
\newdimen\m@length              % duration of scene
\newdimen\m@init                % start of zoom

\newcommand\scene{%
  \@ifnextchar*{\lastframe@true \DN@*{\scene@i}\next@}%
    {\lastframe@false \scene@i}}

\newcommand\scene@i[1][1]{\scene@ii{#1}}

\def\setm@caption#1{\xdef\m@caption{#1}}

\long\def\scene@ii#1#2{{%
    \let\caption=\setm@caption
    \global\advance\m@scene\@ne \edef\theScene{\the\m@scene}%
    \global\m@frame=\z@ \m@length=#1pt \m@init=\z@
    \loop
      \dimen@=\m@frame\m@tick
    \ifdim\dimen@<\m@length
      \scene@frame{#2}%
    \repeat
    \iflastframe@ \scene@frame{#2}\fi
    \dimen@=#1pt \advance\dimen@ by -\m@frame\m@tick
    \ifdim.1\m@tick<\ifdim\dimen@<\z@-\fi\dimen@
      \dimen@=\m@frame\m@tick
      \@warning{scene \the\m@scene\space rounded from #1 to
        \expandafter\unPT@\the\dimen@\space seconds}%
    \fi}\ignorespaces}

\def\scene@frame#1{\frame@compute
  \null
  \vfill
  \hrule width\m@width
  \hbox to\m@width{\hss
    \vbox to\m@height{\hsize=\m@width \null\vfil{#1}\vfil\null}%
    \hss}%
  \setbox0=\hbox{%
    \setbox0=\hbox to\m@width{\hss\fiverm\strut
      \ifm@caption \m@caption \fi
      \ifm@time \quad \m@nicetotal s \fi
      \ifm@count \quad \the\m@scene.%
        \ifnum\m@frame<100 0\ifnum\m@frame<10 0\fi\fi\the\m@frame\fi}%
    \dimen0=\dp0 \ht0=0pt \dp0=0pt \raise\dimen0\box0}%
  \ht0=0pt \dp0=0pt \box0\relax
  \hrule width\m@width
  \global\advance\m@frame\@ne
  \global\advance\m@total\m@tick
  \eject}

\def\frame@compute{%
  \edef\theFrame{\the\m@frame}%
  \dimen@=\m@frame\m@tick \advance\dimen@-\m@init
  \ifdim\dimen@<\z@ \dimen@=\z@ \fi
  \ifdim\dimen@>\m@length \dimen@=\m@length \fi
  \quotient@\theF\dimen@\m@length
  \dimen@=-\dimen@ \advance\dimen@\m@length
  \quotient@\theFr\dimen@\m@length}

\def\m@nicetotal{%
  \edef\tmp{\expandafter\removePT@\the\m@total}%
  \expandafter\twodecimals@\tmp 00@}
\def\twodecimals@#1.#2#3#4@{#1.#2#3}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Triggers.
%
% Triggers are used to make the individual frames in a scene different! :)

% \F{C} expands to C(F) where F = (#frames / frame#) ; 0.0 < F <= 1.0 .
% \Fr{C} expands to C(Fr) where Fr = 1 - F .

\def\F{\expandafter\F@\expandafter{\theF}}
\def\Fr{\expandafter\F@\expandafter{\theFr}}

\def\F@#1#2{#2(#1)}

% \Zoom[A;B]{C} expands C zooming onto the interval [A;B], i.e., within C the
% interval [0;1] really denotes the (current) interval [A;B] ...

% Specifically:   F     F inside [A;B]
%                0;A          0
%                A;B      F-A / B-A
%                B;1          1

\newcommand\Zoom[1][0;1]{\Zoom@#1;}
\def\Zoom@#1;#2;#3{{%
    \dimen@=#1\m@length \advance\dimen@\m@init
    \m@length=#2\m@length \advance\m@length\m@init
    \advance\m@length-\dimen@ \m@init=\dimen@
    \frame@compute #3}}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Preliminary FADING support...
%
% by Ross Moore; depends on Xy-pic `ps' backend...
%
% use as a <shape> modifier:  \drop[<colour>][!\F\lighten]<object>
% use as a <shape> modifier:  \drop[<colour>][!\F\darken}]<object>
%
%  \lighten(1) = white	\lighten(0) = natural colour
%  \darken (1) = black	\darken (0) = natural colour
%
\def\lighten@(#1){/@col #1 def{1 sub 1 @col sub mul 1 add}settransfer}
\def\darken@(#1){/@col #1 def{1 @col sub mul}settransfer}

\xywithoption{ps}{\let\lighten=\lighten@ \let\darken=\darken@}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Dump size file.
%
\AtEndDocument{\dumpsizefile}

\newwrite\m@write

{\catcode`p=12 \catcode`t=12 \gdef\unPT@#1pt{#1}}

\def\dumpsizefile{\immediate\openout\m@write=\jobname.size
%
 \dimen@=1in \divide\dimen@\m@pixel
 \immediate\write\m@write{dpi=\number\dimen@}%
%
 \dimen@=\m@tick \multiply\dimen@ by 1000\advance\dimen@.5\m@tick
 \divide\dimen@\p@ \immediate\write\m@write{delay=\number\dimen@}%
%
 \immediate\write\m@write{loop=\loop@@}%
%
 \immediate\closeout\m@write}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Misc. class-provided commands...

\DeclareOldFontCommand{\rm}{\normalfont\rmfamily}{\mathrm}
\DeclareOldFontCommand{\sf}{\normalfont\sffamily}{\mathsf}
\DeclareOldFontCommand{\tt}{\normalfont\ttfamily}{\mathtt}
\DeclareOldFontCommand{\bf}{\normalfont\bfseries}{\mathbf}
\DeclareOldFontCommand{\it}{\normalfont\itshape}{\mathit}
\DeclareOldFontCommand{\sl}{\normalfont\slshape}{\@nomath\sl}
\DeclareOldFontCommand{\sc}{\normalfont\scshape}{\@nomath\sc}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The End.

\endinput

% $Log: movie.cls,v $
% Revision 3.4  1997/05/18 01:14:25  krisrose
% Essential bugfixes.
%
% Revision 1.5  1997/05/13 12:36:26  krisrose
% Intermediate version; factors function nicely.
%
% Revision 1.4  1997/05/01 21:55:44  krisrose
% Works again.
%
% Revision 1.3  1997/02/11 04:20:19  krisrose
% Fits new dvitogif89a 1.1 :)
%
% Moved to Xy-pic hierarchy.