#tweetcoding Part 2 – Interference, Plasma & Fountain

Following on from my previous post, my first entry is a classic demoscene effect called “Interference”. Two sets of concentric circles intersect and invert each other out, causing crazy MoirĂ© patterns which strobe like early 90s rave visuals. The effect has been used in countless demos on pretty much every platform, but the best example has to be the classic Amiga demo State of the Art by Spaceballs, from back in 1992.

Flash’s even-odd fill rule happily handles the inversion automatically, so all you need to do is draw both sets in one beginFill/endFill block.

Here it is in action.

Interference

c=g.drawCircle;i++;h=s(i*.011)*99;v=s(i*.01)*99;g.clear();g.beginFill(0);for(j=50;j--;){c(275+h,200+v,j*9);c(275-h,200-v,j*9)}

Next up is “Fountain”, another common effect, and probably the most basic particle emitter. A nice side-effect of incrementing the particles’ positions on the lineTo call is that they elongate as their velocity increases. One of those rare situations where an optimisation actually improves the effect.

Another nice optimisation involved the boundary checking. Instead of testing whether a particle has dropped off the bottom of the screen then resetting its position – if(p.y>400){p.x=275;p.y=400} etc – I simply check that its velocity has gone beyond a certain value at the same time as the gravity is applied, then re-use the initialisation code to reset it.

Fountain

g.clear();for(i=99;i--;){!o[i]?o[i]={x:275,y:400,j:r()*4-2,k:-r()*10}:p=o[i];ls(9,i);mt(p.x,p.y);lt(p.x+=p.j,p.y+=p.k);(p.k+=.1)>9?o[i]=0:0}

Third is “Plasma”, another classic demoscene effect going all the way back to the C64 – it’s hard to find an old-school demo that doesn’t feature a plasma effect of some sort. Mario Klingemann (AKA Quasimondo) posted the first entry to use Perlin noise and I set about improving it to use the offsets parameter, causing the octaves to move and interact with each other.

Plasma

p=Point;!o.b?o.c=addChild(new Bitmap(o.b=new BitmapData(550,400,1,0))):o.b.perlinNoise(500,99,2,0,0,1,7,0,[new p(i*9,i*2),new p(-i*9,-i++)])

On to #tweetcoding Part 3.

One Comment

borigia  on January 21st, 2010

real…

Leave a Comment