[metapost] Making flipbooks with TeX

Laurence Finston lfinsto1 at gwdg.de
Wed Aug 10 21:31:47 CEST 2005


Hello,

This is a copy of a posting of mine to the "Advice and Tutorials"
forum of the Animation Corner website:
http://www.animationcorner.com

I thought it might be of interest to MetaPost users.  I don't mention
MetaPost in it, but I used it to make the examples, which I have
attached.

Laurence Finston

******************************************************************

I've finally gotten around to figuring out to make real
flipbooks using TeX.  The following file of TeX code does the trick.
I've uploaded two examples of the result to "Home > Project
Development > Storyboards".  I couldn't think of anywhere better to
put them.

Each image displays the front and back of a single sheet of paper,
properly called the "recto" and the "verso".  I've left a bit of a
margin around the box, because printers are generally not precise
enough.  In the actual PostScript output, there should be a centimeter
of space at the top and left margins of the recto, and the same amount
of space at the top and _right_ margins of the verso.  With a bit of
luck, the boxes will match up when printed. This may require some
adjustments; I haven't tested it yet.

I repeat here what I wrote in my previous posting: By folding a sheet
of paper four times, one gets two gatherings with 8 right-hand pages
each. If the images have been placed properly on the sheet, the edges
can be cut (like old-fashioned books), the left-hand side can be
stapled, and you've got a little book. Half of the images are on each
side of the original sheet, and half of the images on each side are
upside-down.

To use my examples, always fold between the mid-points of the two (current)
long sides.  The paper is folded in the same way for portrait and
landscape, but the upside-down images differ.

To use 'flipbook.tex', you must have 16 images in EPS (Encapsulated
PostScript) format.  They should be of the same size, 4cm x 6.5cm
(width by height) for portrait or 6.5cm x 4cm for landscape.  THE
FRAMES AROUND THE IMAGES ARE PART OF THE IMAGES THEMSELVES!  This is
the way I did it when I made the examples. It's possible to make the
frames part of the TeX file, but it requires a somewhat different
approach.

This example assumes you're using DIN A4 paper.  Since the margins
will have to be cut off anyway, it doesn't matter that much if you're
using a slightly different size, such as 8.5 x 11in paper.  However,
you may have to adjust the '\vsize' (vertical size) and '\hsize'
(horizontal size or line width) values, and the "papersize \special"
for landscape mode.

You'll also need to replace "my_image_<number>.eps" with the names of
your EPS files.  "my_image_0.eps" is a placeholder: it should contain
an empty frame.

If you look at the code below, you will see two lines that look like
this:

%\landscapetrue \landscapefalse

The percent sign is the comment character in TeX, so here,
'\landscapetrue' is commented out and you will get portrait output. If
you want landscape, just comment-out '\landscapefalse' instead.

With a bit of luck, running 'tex flipbook' should produce the file
'flipbook.dvi'.  You'll need to convert it to structured PostScript
(PS) using 'dvips':

dvips -o flipbook.ps flipbook.dvi

You can now view 'flipbook.ps' in Ghostview:

gv flipbook.ps

Or you can print it with 'lpr':

lpr -P<your print queue> flipbook.ps

Or you can convert it to PDF (Portable Document Format):

ps2pdf flipbook.pdf

If all has gone well, you can now print it out, staple the left side,
cut the pages, and start flipping.

If you have more than sixteen images, you'll just have to copy the
code below to make more pages in the same way, and staple the
gatherings together.

As always, if you have any questions, please feel free to ask.

Laurence Finston

%%%% flipbook.tex
%%%% Created by Laurence D. Finston (LDF) Mi Aug 10 16:56:15 CEST 2005

%%%% $Id: flipbook.tex,v 1.5 2005/08/10 17:00:47 lfinsto1 Exp lfinsto1 $

%% * (1) Copyright and License.

%%%% Copyright (C) 2005 Laurence D. Finston

%%%% flipbook.tex 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.

%%%% flipbook.tex 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 flipbook.tex; if not, write to the Free Software
%%%% Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

%% * (1) Code.


%% ** (2) Set margins and spacing.

\advance\voffset by -1in
\advance\hoffset by -1in

\newif\iflandscape

\newdimen\boxlinesize

%\landscapetrue
\landscapefalse

\iflandscape
\special{papersize=297mm, 210mm}
\hsize=297mm
\boxlinesize=23cm
\vsize=21cm
\else
   \hsize=21cm
   \vsize=23cm
\fi

\parskip=0pt
\baselineskip=0pt

%% ** (2)

\input epsf
\nopagenumbers
\def\epsfsize#1#2{#1}

\newskip\vskipvalue
\newskip\hskipvalue

\vskipvalue=-1mm
\hskipvalue=-1mm


\newskip\hmarginvalue
\newskip\vmarginvalue

\hmarginvalue=1cm
\vmarginvalue=1cm


%% ** (2) Landscape.

\iflandscape

%% *** (3) Recto.

\vbox to \vsize{%
\vskip\vmarginvalue
\line{\hskip\hmarginvalue
      \epsffile{my_image_3.eps}\hskip\hskipvalue
      \epsffile{my_image_0.eps}\hskip\hskipvalue
      \epsffile{my_image_5.eps}\hskip\hskipvalue
      \epsffile{my_image_0.eps}\hss}%
\vskip\vskipvalue
%
\line{\hskip\hmarginvalue
      \epsffile{my_image_0.eps}\hskip\hskipvalue
      \epsffile{my_image_11.eps}\hskip\hskipvalue
      \epsffile{my_image_0.eps}\hskip\hskipvalue
      \epsffile{my_image_13.eps}\hss}%
\vskip\vskipvalue
%
\line{\hskip\hmarginvalue
      \epsffile{my_image_15.eps}\hskip\hskipvalue
      \epsffile{my_image_0.eps}\hskip\hskipvalue
      \epsffile{my_image_9.eps}\hskip\hskipvalue
      \epsffile{my_image_0.eps}\hss}%
\vskip\vskipvalue
%
\line{\hskip\hmarginvalue
      \epsffile{my_image_0.eps}\hskip\hskipvalue
      \epsffile{my_image_7.eps}\hskip\hskipvalue
      \epsffile{my_image_0.eps}\hskip\hskipvalue
      \epsffile{my_image_1.eps}\hss}%
\vss
}

%% *** (3) Verso.

\vbox to \vsize{%
\vskip\vmarginvalue
\line{\hss\epsffile{my_image_4.eps}\hskip\hskipvalue
      \epsffile{my_image_0.eps}\hskip\hskipvalue
      \epsffile{my_image_6.eps}\hskip\hskipvalue
      \epsffile{my_image_0.eps}\hskip\hmarginvalue}%
\vskip\vskipvalue
%
\line{\hss\epsffile{my_image_0.eps}\hskip\hskipvalue
      \epsffile{my_image_12.eps}\hskip\hskipvalue
      \epsffile{my_image_0.eps}\hskip\hskipvalue
      \epsffile{my_image_14.eps}\hskip\hmarginvalue}%
\vskip\vskipvalue
%
\line{\hss\epsffile{my_image_16.eps}\hskip\hskipvalue
      \epsffile{my_image_0.eps}\hskip\hskipvalue
      \epsffile{my_image_10.eps}\hskip\hskipvalue
      \epsffile{my_image_0.eps}\hskip\hmarginvalue}%
\vskip\vskipvalue
%
\line{\hss\epsffile{my_image_0.eps}\hskip\hskipvalue
      \epsffile{my_image_8.eps}\hskip\hskipvalue
      \epsffile{my_image_0.eps}\hskip\hskipvalue
      \epsffile{my_image_2.eps}\hskip\hmarginvalue}%

\vss
}




%% ** (2) Portrait.

\else

%% *** (3) Recto.

\vbox to \vsize{%
\vskip\vmarginvalue
\line{\hskip\hmarginvalue
      \epsffile{my_image_0.eps}\hskip\hskipvalue
      \epsffile{my_image_13.eps}\hskip\hskipvalue
      \epsffile{my_image_0.eps}\hskip\hskipvalue
      \epsffile{my_image_1.eps}\hss}%
\vskip\vskipvalue
%
\line{\hskip\hmarginvalue
      \epsffile{my_image_5.eps}\hskip\hskipvalue
      \epsffile{my_image_0.eps}\hskip\hskipvalue
      \epsffile{my_image_9.eps}\hskip\hskipvalue
      \epsffile{my_image_0.eps}\hss}%
\vskip\vskipvalue
%
\line{\hskip\hmarginvalue
      \epsffile{my_image_0.eps}\hskip\hskipvalue
      \epsffile{my_image_11.eps}\hskip\hskipvalue
      \epsffile{my_image_0.eps}\hskip\hskipvalue
      \epsffile{my_image_7.eps}\hss}%
\vskip\vskipvalue
%
\line{\hskip\hmarginvalue
      \epsffile{my_image_3.eps}\hskip\hskipvalue
      \epsffile{my_image_0.eps}\hskip\hskipvalue
      \epsffile{my_image_15.eps}\hskip\hskipvalue
      \epsffile{my_image_0.eps}\hss}%
\vss
}

%% *** (3) Verso.

\vbox to \vsize{%
\vskip\vmarginvalue
\line{\hss\epsffile{my_image_0.eps}\hskip\hskipvalue
      \epsffile{my_image_16.eps}\hskip\hskipvalue
      \epsffile{my_image_0.eps}\hskip\hskipvalue
      \epsffile{my_image_4.eps}\hskip\hmarginvalue}%
\vskip\vskipvalue
%
\line{\hss\epsffile{my_image_8.eps}\hskip\hskipvalue
      \epsffile{my_image_0.eps}\hskip\hskipvalue
      \epsffile{my_image_12.eps}\hskip\hskipvalue
      \epsffile{my_image_0.eps}\hskip\hmarginvalue}%
\vskip\vskipvalue
%
\line{\hss\epsffile{my_image_0.eps}\hskip\hskipvalue
      \epsffile{my_image_10.eps}\hskip\hskipvalue
      \epsffile{my_image_0.eps}\hskip\hskipvalue
      \epsffile{my_image_6.eps}\hskip\hmarginvalue}%
\vskip\vskipvalue
%
\line{\hss\epsffile{my_image_2.eps}\hskip\hskipvalue
      \epsffile{my_image_0.eps}\hskip\hskipvalue
      \epsffile{my_image_14.eps}\hskip\hskipvalue
      \epsffile{my_image_0.eps}\hskip\hmarginvalue}%
\vss
}
\fi  %% \landscapefalse  (Portrait)

\bye
-------------- next part --------------
A non-text attachment was scrubbed...
Name: flpbkprt.ps.gz
Type: application/octet-stream
Size: 83399 bytes
Desc: 
Url : http://tug.org/pipermail/metapost/attachments/20050810/812e7f5b/flpbkprt.ps-0001.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: flpbklnd.ps.gz
Type: application/octet-stream
Size: 84683 bytes
Desc: 
Url : http://tug.org/pipermail/metapost/attachments/20050810/812e7f5b/flpbklnd.ps-0001.obj


More information about the metapost mailing list