Math.pow() == slow && new Array() == slow
Just yesterday I used the Math.pow() function in a project for work and realized, besides it being a function I rarely use, it’s also a pretty slow function. So i came up with a little algorithm that basicaly does the same thing a the Math.pow() function. Lucky me, I was using rounded values, so the custom function takes ints in the params and returns an int. It’s a lot faster, so I thought I would
Bitmap face n°2, now with sound
Another particle exepriment, this time, each particle’s motion is set depending on the overall sound frequency level. I’m not sure how acurate this is, it’s actually probably very wrong, but doesn’t look too bad.
[swfobj src='content/actionscript/as3files/bitmapFaces/soundParticles.swf' width='400' height='400' title='soundParticles.swf']Bitmap face n°1
Quick bitmapData experiment: load a photo, plot particles out using pixel positions from the image, and move the particles, and also add some filters to the bitmapData to make it look a little nicer.
When you click the stage, all the particles ease back to their original positions.
First experiment of a little series, be adding some sound pretty soon, and try and get more particles too.
1205 particles, runs pretty smoothly.
[swfobj src=’content/actionscript/as3files/bitmapFaces/getPixel.swf’ title=’getPixel.swf’ width=’400′
Stars and fake 3D
I’m not sure how interesting this is… just a quick and dirty little trick.
One thing though, the code isn’t optimized, and it might take up quite alot of resource.
Feel free to grab the source.
Lots of little star particles repeled by the mouse:
[swfobj src='content/actionscript/as3files/avoid.swf' title='avoid.swf' width='512' height='300']more of little star particles repeled by the mouse, this in time in pseudo 3D:
[swfobj src='content/actionscript/as3files/avoid3D.swf' title='avoid3D.swf' width='512' height='300']