Sam's Java Plasma Applet

Today I thought I'd try to learn Java. I started (after lunch at about 13:30) with something simple - a Hello World program that I got from the Sun site. Simple. And dull. So I was casting about for some other program to write that would be just a tad more interesting, and I remembered a comment I saw once on Somebody said "Why not write a demo in Java?". At the time, I thought this was a pretty damn stupid idea. I still do. Six hours later, watching my little applet run at 1 frame per second as I write this, I hope I've proved something to that person.

You won't see anything unless you enable Java. Make sure you're using Netscape 2 or better on a system that supports Java (Windows 95, Windows NT, X-Windows) and make sure that Java is enabled from the "Options.. Security Preferences" menu option.

This plasma routine is a simple sum of four sine waves. The sine values are stored in a table, not calculated realtime or anything silly; this is a port from ASM code I had lying around. Since the bitmap is colourspace-converted anyway, I could have used true-colour, but that would have slowed it down by a factor of 3. So I didn't. Various tricks have been used to speed up the code; what you're seeing is a 64 by 64 plasma, size-multiplied three times. For comparison, an identical routine, written in ASM and displaying a 320x200 image, gets over 30 fps on a 486-33. (And it might be 70fps. I haven't checked.)

Things to remember about Java, number one: it's an interpreted language. That means slow, slow, and slow. So don't try to write a demo in it, okay? Please?

Oh, finally, a little challenge: This code is quite probably very shit. After all, six hours ago I'd never looked at any Java source code or documentation... If anybody can be bothered, maybe wants some practice for their own Java skills - why not try to make a faster version of the same program. (4 sinewaves - 2 x and 2 y, 256-colour paletting, 64x64 size multiplied 3 times).

If you bother trying that, or if you want to make any comments about the program, get in touch. Thanks!

Check out the Software Forge homepage, featuring music utilities and iNETRiS internet tetris