home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Pascal / Snippets / GammaFade / NewFader.p < prev    next >
Encoding:
Text File  |  1995-08-06  |  2.3 KB  |  89 lines  |  [TEXT/MWPS]

  1. {----------------------------------------------------------------------
  2.  
  3. Gamma Fading library originally coded in Think C on 12/17/92 by Matt Slot.
  4. Gamma Fading library converted to Think Pascal on 7/18/95 by Matthew Mora.
  5.  
  6. On 8/5/95, Bill Catambay ported the library to CodeWarrior pascal for 68K and PPC, 
  7. and wrote this program to demonstrate the Gamma routines.
  8.  
  9. Files in project:
  10.  
  11. NewFader.p  -  This test program for performing a slow fade out, a fast fade in, and
  12.                then a fast fade out and a slow fade in.
  13. GammaPaslib.p  -  The Pascal gamma routines and internal type declarations.
  14. NewFader.µ.rsrc  -  Resources for this program.
  15. NewFader(68K).µ  -  The 68K CW Pascal project.
  16. NewFader(PPC).µ  -  The PPC CW Pascal project.
  17.  
  18. Bill Catambay - catambay@aol.com
  19. ----------------------------------------------------------------------}
  20. Program DoubleFade;
  21.  
  22. Uses
  23.     SegLoad, Fonts, ToolUtils, Resources, Sound, GammaPaslib;
  24.  
  25. Const
  26.     buttonClick    = 128;
  27.     
  28. Var
  29.     oe:         integer;
  30.     myrect:     rect;
  31.     mywindow:     windowPtr;
  32.     mypicture:     pichandle;
  33.  
  34. Procedure Toolbox_init;
  35.  
  36.     begin
  37.     InitGraf(@qd.thePort);
  38.     InitFonts;
  39.     InitWindows;
  40.     InitMenus;
  41.     TEinit;
  42.     InitDialogs(nil);
  43.     MaxApplZone;
  44.     InitCursor;
  45.     end;
  46.  
  47. Procedure Do_sound(snd_id: integer);
  48.  
  49. Var
  50.     snd:    handle;
  51.     
  52.     begin
  53.     snd := GetResource(soundListRsrc,snd_id);
  54.     if snd = NIL then
  55.         exit(Do_sound);
  56.     oe := SndPlay(NIL,sndlisthandle(snd),FALSE);
  57.     ReleaseResource(snd);
  58.     end; { of do_sound }
  59.     
  60. begin
  61. Toolbox_init;
  62. if not IsGammaAvailable then
  63.     exittoshell;
  64. oe := SetupGammaTools;
  65. mypicture := GetPicture(128); 
  66. Hlock(Handle(mypicture));
  67. { Center the window }
  68. myrect := myPicture^^.picFrame;
  69. OffsetRect(myRect, (qd.screenBits.bounds.right - myrect.right) div 2, 
  70.     (qd.screenBits.bounds.bottom - myrect.bottom) div 2);
  71. { Slow Fade the screen to black and display the window }
  72. DelayFadeToBlack(1);
  73. mywindow := NewCWindow(NIL, myrect, '', TRUE, plainDBox ,pointer(-1), FALSE, 0);
  74. SetPort(mywindow);
  75. DrawPicture(mypicture, mypicture^^.picFrame);
  76. HUnlock(Handle(mypicture));
  77. ReleaseResource(Handle(mypicture));
  78. { Fade the screen back in and wait for mouse button }
  79. FadeFromBlack(2);
  80. repeat
  81. until Button;
  82. Do_sound(buttonClick);
  83. { Fade the screen to black again, remove the window, then slow fade back in }
  84. FadeToBlack(2);
  85. HideWindow(mywindow);
  86. DelayFadeFromBlack(1);
  87. oe := DisposeGammaTools;
  88. end.
  89.