[comp.sys.mac] LightSpeed C special effects

tedj@hpcid.HP.COM (Ted Johnson) (09/15/87)

I am working with LightSpeed C (2.01) on a Mac SE HD 20 and have been
trying to duplicate 3 cool "special effects" that I have seen done
on some other programs.  Any and all help & source code that you can give
me is sincerely appreciated.  The special effects are:

				1)showing one PICT picture (or a
				   line of text) and then dissolving
				   that picture (or text) to show
			   	   another picture (or text) beneath
				   it.

				2)expanding a line of text inside a
				  window, making it seem to explode.
			          One way to do this would be to just
				  keep changing the font size (10, 12, etc).
				  Is there a better way?

				3)the "Star Trek" effect, like in
				  LightSpeed C's About... box.

Please post replies to the net, as I'm not sure mail will get to me and I'm
sure other programmers are interested in these issues also.  If
you want to try mailing me stuff, try the following addresses:  

							hpcid!tedj@hplabs.COM
						or      tedj@hpcid@hplabs.COM
					       or   tedj@hpcillm.dtc.hp.com
Thanks!

Ted Johnson
(408)553-3555

cnc@hpcid.UUCP (09/16/87)

>			1)showing one PICT picture (or a
>			   line of text) and then dissolving
>			   that picture (or text) to show
>		   	   another picture (or text) beneath
>			   it.

I understand that Lisa Pascal had a routine called DissBits. Does 
anyone have any information on this routine?

--------------------------------------------------------------------------------
Chris Christensen				Hewlett-Packard
(408) 553-2955 or telnet 553-2955		Design Technology Center
cnc@hpcid.hp.com				Santa Clara, CA

oster@dewey.soe.berkeley.edu (David Phillip Oster) (09/17/87)

In article <3320011@hpcid.HP.COM> tedj@hpcid.HP.COM (Ted Johnson) asks how
to do a few things:
As the author of Stars, I feel qualified to answer.
>1)showing one PICT picture (or a line of text) and then dissolving
> that picture (or text) to show another picture (or text) beneath it.
Think of a picture, say 1000x1000 pixels as consisting of pixels
numbered 0 to 999999. If you replaced each pixel in the original in
order by a pixel from the new picture, the new picture would appear in
scan line bands.  Suppose you "shuffled" the numbers from 0 to 999999
and used that shuffleto bring in pixels from the new picture. Since
the human eye has a bad memory for randomness, you only have to
shuffle them once, and you can reuse that shuffle and have it still
look good.  The shuffle is encoded as a pseudo-random number generator
that has a non-repitition period longer than the number of pixels in
the picture.  The design of such random number generators is given in
Knuth's Art of Computer Programming, Vol 1. Semi-Numerical Algorithms.
In addition, there wave been articles on exactly how to do this
published in MacTutor magazine.

>2)expanding a line of text inside a window, making it seem to
> explode. One way to do this would be to just keep changing the font
> size (10, 12, etc). Is there a better way?

Pre-render the different sized images and save the successive images
as PICTs. Flash the PICTs on the screen with DrawPicture.  Pre-load
and HNoPurge() the PICTs from disk before going into your animation
cycle, so that there will be no embarassing disk waits while you are
animating.  Remember that DrawPicture will scale its PICT arg to
whatever rectangle you tell it (so you can enlarge something to make
it really big.)


>3)the "Star Trek" effect, like in LightSpeed C's About... box.

This should be "Star Wars Hyperspace" effect.

Start with a "galaxy of stars ": an array of points in 3 space. I use
-4000 < x < 4000, -4000 < y < 4000, 0 < z < 150. Points are initially
randomly distributed within these ranges. You simulate moving through
the space by decrementing the Z coordinates of all the stars.  You
project from 3space to 2space with:
x2 = x3/z3
y2 = y3/z3
If, after the decrement, the star has moved on the screen, you erase
it from its old position (a CopyBits in Xor mode) and draw it in its
new position (a CopyBits in Xor mode.)  If the "z" of a star goes to
zero, then you've passed it. Create a new star on the horizon (i.e.
with Z = Zmax.)

That gives you your normal space travel effect. Now for HyperSpace:
Save the initial positions of all the stars. Now, animate until you've
passed all the stars, as above, only this time don't do any erasing.
Once you've passed everything, restore the initial state and do it
again, only this time the Xor drawing will erase everything that was
on the screen before. You can use OR and AND if Xor scares you for
this.

--- David Phillip Oster            --My Good News: "I'm a perfectionist."
Arpa: oster@dewey.soe.berkeley.edu --My Bad News: "I don't charge by the hour."
Uucp: {uwvax,decvax,ihnp4}!ucbvax!oster%dewey.soe.berkeley.edu