home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Libraries / Graphic Elements 2 / Extras / SFXProcs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-24  |  2.5 KB  |  111 lines  |  [TEXT/MMCC]

  1. /*
  2.     SFXProcs.h
  3.     
  4.     Special effects for Graphic Elements
  5.     
  6.     Copyright 1994 by Al Evans. All rights reserved.
  7.     
  8.     6/9/94
  9.     
  10. */
  11.  
  12. #include "Rects.h"
  13. #include "SFXProcs.h"
  14.  
  15. /*
  16.     Special effects procs:
  17.     
  18.     There are two special cases for controller->currentStep.
  19.     
  20.     if (controller->currentStep == 0), the controller is being constructed, and the
  21.     special effect procedure may allocate memory and do any setup it needs to do. It
  22.     may store a pointer to its data in controller->sfxData.
  23.     
  24.     if (controller->currentStep == -1), the special effect is finished, and it should
  25.     free any memory it has allocated.
  26. */
  27.  
  28. pascal void SFXHWipe(SFXCtrlrPtr controller)
  29. {
  30.     Rect        destRect;
  31.     CGrafPtr    savePort;
  32.     GDHandle    gd;
  33.     GrafElPtr    element = (GrafElPtr) controller;
  34.     short        cpyWidth;
  35.     
  36.     switch(controller->currentStep) {
  37.         case -1:
  38.             break;
  39.         case 0:
  40.             break;
  41.         default:
  42.             GetGWorld(&savePort, &gd);
  43.             SetGWorld(element->graphWorld, nil);
  44.             destRect = element->graphRect;
  45.             cpyWidth = RectWidth(&destRect) * controller->currentStep / controller->nSteps;
  46.             if (controller->forward)
  47.                 destRect.right = destRect.left + cpyWidth;
  48.             else
  49.                 destRect.left = destRect.right - cpyWidth;
  50.             CopyBits(&((GrafPtr) controller->sfxSrc)->portBits, 
  51.                         &((GrafPtr) element->graphWorld)->portBits,
  52.                         &destRect, &destRect, srcCopy, nil);
  53.             SetGWorld(savePort, gd);
  54.             
  55.             
  56.             break;
  57.     }
  58. }
  59.  
  60. pascal void SFXVWipe(SFXCtrlrPtr controller)
  61. {
  62.     Rect        destRect;
  63.     CGrafPtr    savePort;
  64.     GDHandle    gd;
  65.     GrafElPtr    element = (GrafElPtr) controller;
  66.     short        cpyHeight;
  67.     
  68.     switch(controller->currentStep) {
  69.         case -1:
  70.             break;
  71.         case 0:
  72.             break;
  73.         default:
  74.             GetGWorld(&savePort, &gd);
  75.             SetGWorld(element->graphWorld, nil);
  76.             destRect = element->graphRect;
  77.             cpyHeight =  RectHeight(&destRect) * controller->currentStep / controller->nSteps;
  78.             if (controller->forward)
  79.                 destRect.bottom = destRect.top + cpyHeight;
  80.             else
  81.                 destRect.top = destRect.bottom - cpyHeight;
  82.             CopyBits(&((GrafPtr) controller->sfxSrc)->portBits, 
  83.                         &((GrafPtr) element->graphWorld)->portBits,
  84.                         &destRect, &destRect, srcCopy, nil);
  85.             SetGWorld(savePort, gd);
  86.             
  87.             
  88.             break;
  89.     }
  90. }
  91.  
  92. pascal void SFXBlink(SFXCtrlrPtr controller)
  93. {
  94.     GWorldPtr    tmpGWorld;    
  95.     
  96.     switch(controller->currentStep) {
  97.         case -1:
  98.             break;
  99.         case 0:
  100.             break;
  101.         default:
  102.             //Total number of switches must be even
  103.             if ((controller->currentStep == controller->nSteps) && (controller->nSteps & 1))
  104.                 return;
  105.             tmpGWorld = controller->sfxSrc;
  106.             controller->sfxSrc = ((GrafElPtr) controller)->graphWorld;
  107.             ((GrafElPtr) controller)->graphWorld = tmpGWorld;
  108.             break;
  109.     }
  110. }
  111.