Copyright ã 1997 by Mark Probst. All Rights Reserved.  

MiscImageDissolver

Inherits From:	View : Responder : Object
Declared In:	MiscImageDissolver.h

Class Description

MiscImageDissolver is a View that is able of not only displaying an image but also of smoothly dissolving from one image into another.  The parameters of the dissolving process are the number of steps and the duration of one step.

Note that the methods dissolveToImage: and dissolveOverImageList: only start a dissolving process and return immediately.  The dissolving is taken out in the background (by virtue of a timed entry). 

Instance Variables

NXImage *sourceImage;
NXImage *destImage;
List *imageList;
int numSteps;
double secs;
int currentStep;
int currentIndex;
char *image1Name;
char *image2Name;
DPSTimedEntry timedEntry; 

sourceImage	A pointer to the image currently displayed.

destImage	A pointer to the image currently dissolved to.

imageList	A pointer to the image list currently dissolved over.

numSteps	The number of steps of the dissolving process.

secs	The number of seconds between two steps.

currentStep	The current dissolving step or < 0 if finished.

currentIndex	The current index in imageList of the image currently dissolved to.

image1Name	The name of an image

image2Name	The name of another image

timedEntry	The timed entry for the dissolving process.

Method Types

Initializing and freeing	- initFrame:
	- free

Dissolving parameters	- numSteps
	- setNumSteps:
	- stepInterval
	- setStepInterval:

Convenience	- image1Name
	- setImage1Name:
	- image2Name
	- setImage2Name:

The image	- image
	- setImage:

Dissolving	- dissolveToImage:
	- dissolveOverImageList:
	- dissolveToImage1:
	- dissolveToImage2:
	- dissolveToOtherImage:
	- dissolveBackAndForth:
	- hasFinished

Displaying	- drawSelf::
	- dissolveStep

Archiving	- read:
	- write:

Instance Methods

dissolveBackAndForth:

- dissolveBackAndForth:sender

This method dissolves over the two images named image1Name and image2Name.  If the currently displayed image is image1Name, it dissolves first to image2Name and then back to image1Name, otherwise it dissolves the other way round.

This method works by calling dissolveOverImageList:.

Returns self on success, and nil otherwise. 

dissolveOverImageList:

- dissolveOverImageList:(List*)theList

Starts a dissolving process over the list theList.  theList must contain pointers to NXImage's.  The current image is dissolved to the first element in the list, which in turn is then dissolved to the second etc.

If everything is in order and the dissolving has been started, this method returns self.  Otherwise, returns nil.

If the methods returns self, you can assume that the list will be freed.  Otherwise, you have to free it yourself. 

dissolveStep

- dissolveStep

Does one step in the dissolving process.  You do not call this method directly.  It is called from the timed entry function instead.  Returns self. 

dissolveToImage1:

- dissolveToImage1:sender

Dissolves to an image named image1Name using the method dissolveToImage:.

Returns self on success, and nil otherwise. 

dissolveToImage2:

- dissolveToImage2:sender

Dissolves to an image named image2Name using the method dissolveToImage:.

Returns self on success, and nil otherwise. 

dissolveToImage:

- dissolveToImage:(NXImage*)theImage

Starts a dissolving process to theImage, if dissolving is not already in progress, and returns self.  Otherwise, returns nil. 

dissolveToOtherImage:

- dissolveToOtherImage:sender

Dissolves to the image named image2Name, if sourceImage is the image named image1Name.  Otherwise dissolves to the image named image1Name.  In other words: If the currently displayed image is either of image1Name or image2Name, this method dissolves to the other one, and dissolves to image1Name if the currently displayed image is neither of the two.

This method uses dissolveToImage:.

Returns self on success, and nil otherwise. 

drawSelf::

- drawSelf:(const NXRect*)rects  :(int)rectCount

Draws the MiscImageDissolver object and returns self. 

free

- free

Frees the MiscImageDissolver instance. 

hasFinished

- (BOOL)hasFinished

Returns YES if there is no dissolving in progress.  Otherwise, returns NO. 

image

- (NXImage*)image

Returns sourceImage. 

image1Name

- (const char*)image1Name

Returns image1Name. 

image2Name

- (const char*)image2Name

Returns image2Name. 

initFrame:

- initFrame:(const NXRect*)rect

Initializes the MiscImageDissolver object and sets sourceImage to the image named image1Name (if set), otherwise to the image named "ImageDissolver" (if available).  The number of steps is set to 20 and the duration of a step is set to 0.05 seconds.

This is the designated initializer for MiscImageDissolver. 

numSteps

- (int)numSteps

Returns the number of steps of the dissolving process. 

read:

- read:(NXTypedStream*)theStream

Reads the MiscImageDissolver object in from the typed stream theStream.  Returns self. 

setImage1Name:

- setImage1Name:(const char*)theName

Sets image1Name to the string pointed to by theName. 

setImage2Name:

- setImage2Name:(const char*)theName

Sets image2Name to the string pointed to by theName. 

setImage:

- setImage:(NXImage*)theImage

Sets the image displayed to theImage, if dissolving is not in progress, and returns self.  Otherwise, returns nil. 

setNumSteps:

- setNumSteps:(int)theNumSteps

Sets the number of steps of the dissolving process to theNumSteps. 

setStepInterval:

- setStepInterval:(double)theSeconds

Sets the duration of a dissolving step to theSeconds. 

stepInterval

- (double)stepInterval

Returns the duration of one dissolving step in seconds. 

write:

- write:(NXTypedStream*)theStream

Writes the MiscImageDissolver object to the typed stream theStream.  Returns self.