Re: [RANT] Unfair preferential treatment of Microsoft
Re: [RANT] Unfair preferential treatment of Microsoft
- Subject: Re: [RANT] Unfair preferential treatment of Microsoft
- From: Nat! <email@hidden>
- Date: Fri, 21 Sep 2001 00:07:49 +0200
I don't think you have to be a genius to code some kind of genie effect.
There is probably only one transparent window, with a transparent image
that uses either horizontal or vertical pixel scalers (depending on
where to move to) to squish and expand. Such a pixel scaler is analogous
to texture mapping where the source and the destination are just one
horizontal or vertical line (easy :))
//
// This code shows the principle (not more!)
// src points to the beginning of the texture of size pixels
// dst points to the start of the line to draw of w pixels
//
pixel_scaler_hor( Pixel *dst, unsigned int w, Pixel *src, unsigned int
size)
{
float step;
float x;
if( w)
{
x = 0;
step = size / w;
do
{
*dst++ = src[ (int) (x + 0.5)]; // could interpolate
x += step;
}
while( --w);
}
}
Now the window and the image are rapidly redrawn, with varying
compressions and offsets for the lines to give the animation effect.
The niceness of the Apple effect is the way the window contents curves
and moves.
Here are the steps I would do to get an effect like this. I am pretty
sure it will work, in what kind of performance I can't say. This is for
scaling down...
1. Capture window contents (contentView) in NSBitmapImageRep using
initWithFocusedViewRect:
2. Decide size and position of minimized view. Decide whether to squish
horizontally or vertically (is the destination more offset horizontally
(squish vertically) or vertically (squish horizontally))
3. Compute the rectangle that would encompass the minimized and
non-minimized view (e.g.. dock position and current position)
3. Create another NSBitmapImageRep with this dimension, create a
borderless, non-opaque, shadowless window with this dimension. (notice
how shadows vanish in the Apple jinny effect...)
3. Replace original window with new Window.
4. Paint original NSBitmapImageRep into window (use a contentView, that
uses our new NSBitmapImageRep in drawRect:). Display window. Since this
window is mostly transparent, mouse clicks will go through, where we
don't paint.
5. Start a timer
6. Whenever the time fires use some particle like math to create the
desired positions and widths or heights for each squished line (This
will probably take most of the coding time to make a nice looking
effect). Apply scaling algorithm for each line, drawing into a
NSBitmapImageRep (previously cleared with "ClearColor").
6. Stop timer when animation is done
7. Remove transparent window
Performance will mostly be limited by the redrawing speed of the
transparent window. You can optimize the scaler so that it won't be an
issue...
Nat! (crusty ol' Atari hacker)