[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Window zooming effect



here's a C++ version of a zooming routine that I use for windows
or things inside of windows.  sorry,  I don't have the equivalent
lisp code,  but if I get around to making it I'll post it.

void ZoomIt(Rect r1, Rect r2, Boolean useWMPort = false);
 
// function ZoomIt
// Copyright (C) 1992 John Montbriand.  All Rights Reserved.
 
void ZoomIt(Rect r1, Rect r2, Boolean useWMPort) {
 GrafPort wPort;
 PenState lastPen;
 if (useWMPort) OpenPort(&wPort); else GetPenState(&lastPen);
   PenMode(patXor);
   PenPat(qd.gray);
   const float zoomcount = 10;
   const int kZQSize = 5;
   const float TSlope = (r2.top - r1.top) / zoomcount;
   const float LSlope = (r2.left - r1.left) / zoomcount;
   const float BSlope = (r2.bottom - r1.bottom) / zoomcount;
   const float RSlope = (r2.right - r1.right) / zoomcount;
   Rect zoomq[kZQSize];
   for (int x=0; x < kZQSize; x++) SetRect(zoomq+x, 0, 0, 0, 0);
   for (int i = 0; i <= (int) zoomcount+kZQSize; i++) {
     long finalTicks;
     Rect r;
     if (!EmptyRect(zoomq + i % kZQSize)) FrameRect(zoomq + i % kZQSize);
     if (i <= (int) zoomcount) {
       const float j = i - (zoomcount/3.1415)*sin((3.1415/zoomcount)*i);
       r.top = (short) (j * TSlope + r1.top);
       r.left = (short) (j * LSlope + r1.left);
       r.bottom = (short) (j * BSlope + r1.bottom);
       r.right = (short) (j * RSlope + r1.right);
       FrameRect(&r);
       zoomq[i % kZQSize] = r;
     }
     Delay(1, &finalTicks);
   }
 if (useWMPort) ClosePort(&wPort); else SetPenState(&lastPen);
}
// end of function ZoomIt

   -john