home *** CD-ROM | disk | FTP | other *** search
- #include "gGlobals.h"
-
- /*********************************************
- File: RollPicture.c
- By R. Mark Fleming.
-
- Roll a picture from left ot right, right to left,
- up to down, down to up.
-
- History...
- Dec. 1993 RMF Modified for use with QuickTime code from other Pysc Animation projects.
-
- Options:
-
- fill = 0 if roll image around instead of sliding the image into the picture frame.
- direction = four possible direction of movement supported.
- stageNum = the stage image to be producted
- totalStages = number of stage the image is to be used to create full transition.
- *********************************************/
-
- void DoRoll(long stageNum,long totalStages, int direction, int fill)
- {
- GWorldPtr saveWorld;
- GDHandle saveGD;
- RGBColor opColor;
-
- register int i, steps;
- Rect rTemp, rLeft, rRight, r, r2;
-
- if (totalStages == 0) { SysBeep(0); return; }
-
- rTemp = gWorld->portRect;
-
- if (direction == 1 || direction == 2) i = rTemp.right - rTemp.left;
- else i = rTemp.bottom - rTemp.top; /* Get Width or Height */
-
- if (totalStages >= i) { /* Get step size */
- steps = 1;
- } else steps = (i / ((long)totalStages)) + 1L;
-
- switch (direction) { /* Set starting pos. */
- case 1: /* Left to Right */
- i = rTemp.left;
- break;
-
- case 2: /* Right to Left */
- i = rTemp.right;
- break;
-
- case 3: /* Roll Up */
- i = rTemp.top;
- break;
-
- case 4: /* Roll Down */
- i = rTemp.bottom;
- break;
- }
-
-
- do {
-
- r2 = r = rRight = rLeft = rTemp; /* Use min. area of image */
- if (stageNum) {
- #if 0
- switch (direction) {
- case 1: /* Left to Right */
- i += steps;
- if (i >= rTemp.right) i = rTemp.left + steps;
- break;
-
- case 2: /* Right to Left */
- i -= steps;
- if (i < rTemp.left) i = rTemp.right - steps;
- break;
-
- case 3: /* Roll Up */
- i += steps;
- if (i > rTemp.bottom) i = rTemp.top + steps;
- break;
-
- case 4: /* Roll Down */
- i -= steps;
- if (i < rTemp.top) i = rTemp.bottom - steps;
- break;
- }
- #else
- switch (direction) {
- case 1: /* Left to Right */
- i += steps;
- if (i >= rTemp.right) i = rTemp.right;
- break;
-
- case 2: /* Right to Left */
- i -= steps;
- if (i < rTemp.left) i = rTemp.left;
- break;
-
- case 3: /* Roll Up */
- i += steps;
- if (i > rTemp.bottom) i = rTemp.bottom;
- break;
-
- case 4: /* Roll Down */
- i -= steps;
- if (i < rTemp.top) i = rTemp.top;
- break;
- }
- #endif
- }
-
- if (direction == 1 || direction == 2) { /* Left-Right scroll ! */
- /* Destinations...
- * +------------------------+--------------------+
- * L.left -- L.right i R.left -- R.right */
- rLeft.right = i; /* Left Rect (dest of right over hang) */
- rRight.left = i; /* Right Rect (dest of left part of image) */
- /* Source...
- * +-----------------------+--------------------+
- * r2.left --- r2.right L.left r.left --- r.right */
- r.left = r.right - (rLeft.right - rLeft.left); /* Left Edge */
- r2.right = r2.left + (rRight.right - rRight.left); /* Right Edge */
- } else { /* up - down scroll ! */
- /* Destinations...
- * +------------------------+--------------------+
- * L.left -- L.right i R.left -- R.right */
- rLeft.bottom = i; /* Top Rect (dest of right over hang) */
- rRight.top = i; /* Bottom Rect (dest of left part of image) */
- /* Source...
- * +-----------------------+--------------------+
- * r2.left --- r2.right L.left r.left --- r.right */
- r.top = r.bottom - (rLeft.bottom - rLeft.top); /* bottom Edge */
- r2.bottom = r2.top + (rRight.bottom - rRight.top); /* top Edge */
- }
-
- } while (stageNum-- > 0);
-
-
- GetGWorld(&saveWorld,&saveGD);
-
- SetGWorld(gDstWorld,nil);
-
- /* Use offscreen buffer... setup image... */
- CopyBits( (BitMap*)*gWorld->portPixMap, (BitMap*)*gDstWorld->portPixMap,
- &r, &rLeft, srcCopy, 0L);
-
- if (fill == 0)
- CopyBits( (BitMap*)*gWorld->portPixMap, (BitMap*)*gDstWorld->portPixMap,
- &r2, &rRight, srcCopy, 0l);
- else
- EraseRect(&rRight);
-
- SetGWorld(saveWorld,saveGD);
-
- }
-
-
- void DoFlipIn(long stageNum,long totalStages, int direction)
- {
- GWorldPtr saveWorld;
- GDHandle saveGD;
- RGBColor opColor;
-
- register int i, steps;
- Rect rLeft, rRight, r, r2;
-
- rLeft = gWorld->portRect;
- i = rLeft.right - rLeft.left;
- if (totalStages == 0) { SysBeep(0); return; }
- if (totalStages > i) totalStages = i;
- steps = (i / ((long)totalStages)) + 1L;
-
- if (direction == 1 || direction == 2) i = gWorld->portRect.left + steps;
- else i = gWorld->portRect.top + steps;
-
- r2 = r = rRight = rLeft = gWorld->portRect; /* Use min. area of image */
-
- do {
- r2 = r = rRight = rLeft = gWorld->portRect; /* Use min. area of image */
- switch (direction) {
-
- case 1: /* Left to Right */
- i += steps;
- if (i >= gWorld->portRect.right) i = gWorld->portRect.left + steps;
- break;
-
- case 2: /* Right to Left */
- i -= steps;
- if (i < gWorld->portRect.left) i = gWorld->portRect.right - steps;
- break;
-
- case 3: /* Roll Up */
- i += steps;
- if (i > gWorld->portRect.bottom) i = gWorld->portRect.top + steps;
- break;
-
- case 4: /* Roll Down */
- i -= steps;
- if (i < gWorld->portRect.top) i = gWorld->portRect.bottom - steps;
- break;
- }
-
- if (direction == 1 || direction == 2) { /* Left-Right scroll ! */
- /* Destinations...
- * +------------------------+--------------------+
- * L.left -- L.right i R.left -- R.right */
- rLeft.right = i; /* Left Rect (dest of right over hang) */
- rRight.left = i; /* Right Rect (dest of left part of image) */
- /* Source...
- * +-----------------------+--------------------+
- * r2.left --- r2.right L.left r.left --- r.right */
- r.left = r.right - (rLeft.right - rLeft.left); /* Left Edge */
- r2.right = r2.left + (rRight.right - rRight.left); /* Right Edge */
- } else { /* up - down scroll ! */
- /* Destinations...
- * +------------------------+--------------------+
- * L.left -- L.right i R.left -- R.right */
- rLeft.bottom = i; /* Top Rect (dest of right over hang) */
- rRight.top = i; /* Bottom Rect (dest of left part of image) */
- /* Source...
- * +-----------------------+--------------------+
- * r2.left --- r2.right L.left r.left --- r.right */
- r.top = r.bottom - (rLeft.bottom - rLeft.top); /* bottom Edge */
- r2.bottom = r2.top + (rRight.bottom - rRight.top); /* top Edge */
- }
-
- } while (stageNum-- > 0);
-
-
- GetGWorld(&saveWorld,&saveGD);
-
- SetGWorld(gDstWorld,nil);
-
- /* Use offscreen buffer... setup image... */
- CopyBits( (BitMap*)*gWorld->portPixMap, (BitMap*)*gDstWorld->portPixMap,
- &r, &rLeft, srcCopy, 0L);
-
- CopyBits( (BitMap*)*gAltWorld->portPixMap, (BitMap*)*gDstWorld->portPixMap,
- &r2, &rRight, srcCopy, 0l);
-
- SetGWorld(saveWorld,saveGD);
-
- } /* End of () */