AISAnimation.mesa
Copyright © 1984 by Xerox Corporation. All rights reserved.
Last Edited by: May 4, 1985 9:42:42 am PDT
Crow, May 23, 1986 3:53:16 pm PDT
DIRECTORY
ThreeDScenes  USING [Context],
Pixels     USING [PixelBuffer],
Rope     USING [ROPE];
AISAnimation: CEDAR DEFINITIONS
~ BEGIN
Basic Types
FrameSequence: TYPE ~ RECORD[ currentFrame: NAT ← 0, length: NAT,
          frames: SEQUENCE maxLength: NAT OF Pixels.PixelBuffer ];
AISAnimationError: SIGNAL [reason: ATOM];
Procedures for Animation - These build sequences of AIS files and play them back
Plays back a sequenced set of AIS files, cycling through the files ad nauseum
- startNum specifies the first image in the sequence to display
- numFiles specifies the number of different images to be displayed
- framesPerSec ranges from 1 up to 30 (performance is limited by BLT speed)
- secondsPlayingTime limits the running time
PlayBackNumberedAISFiles: PROC[context: REF ThreeDScenes.Context, fileRoot : Rope.ROPE,
         startNum, numFiles, framesPerSec, secondsPlayingTime : NAT];
Stores image on display in named file, sequence number is added to file name
StoreFiles: PROC[context: REF ThreeDScenes.Context, fileRoot: Rope.ROPE, number: NAT];
These store a cache of images in memory for flexible playback, return a handle to the cache
CacheAISFiles: PROC[context: REF ThreeDScenes.Context, fileOfNames: Rope.ROPE,
       frames: REF FrameSequence ← NIL]
     RETURNS[REF FrameSequence];
CacheNumberedAISFiles: PROC[context: REF ThreeDScenes.Context, fileRoot: Rope.ROPE,
           numFiles: NAT, start: NAT ← 0]
        RETURNS[REF FrameSequence];
Plays back a cached set of images as above, will cycle through the sequence or run back and forth over the sequence if bothWays is set TRUE, the playback may be started in midsequence if startNum is nonzero
PlayBackAISCache: PROC[context: REF ThreeDScenes.Context, frames: REF FrameSequence,
        framesPerSec, secondsPlayingTime: NAT,
        bothWays: BOOLEANFALSE, startNum: NAT ← 0];
Shows next frame in sequence, delaying enough time to ensure framesPerSec not exceeded, handy for interactive control of frame rate, negative framesPerSec shows previous frame
ShowNextAISCacheFrame: PROC[context: REF ThreeDScenes.Context,
          frames: REF FrameSequence, framesPerSec: INTEGER ← 0];
Support Procedures
Shuts down playback from another process
StopDisplay: PROC [];

Adds number to the file name, sticking it in just before the extension, for sequencing
PasteInSequenceNo: PROC[fileRoot: Rope.ROPE, number: NAT] RETURNS[Rope.ROPE];

Shows the specified frame
ShowAISCacheFrame: PROC[context: REF ThreeDScenes.Context, frames: REF FrameSequence];
The following loadAIS files into a displayed context without resampling.
- If the stored image has more pixels than the display, part will be clipped.
- If the stored image has fewer pixels than the display, an unwritten border will be left around the displayed image.
- xOffset moves the displayed to the right if positive, otherwise left (units are pixels)
- yOffset moves the displayed up if positive, otherwise down
GetAIS: PROC[context: REF ThreeDScenes.Context, fileRoot: Rope.ROPE,
       xOffset, yOffset: INTEGER ← 0, center: BOOLEANTRUE]
     RETURNS
[ xSize, ySize: INTEGER];      
PutAIS: PROC[context: REF ThreeDScenes.Context, fileRoot: Rope.ROPE];
GetInterpress: PROC[context: REF ThreeDScenes.Context, fileRoot: Rope.ROPE,
       xOffset, yOffset: INTEGER ← 0, center: BOOLEANTRUE]
     RETURNS
[ xSize, ySize: INTEGER];      
PutInterpress: PROC[context: REF ThreeDScenes.Context, fileRoot: Rope.ROPE];
END.