Objects with multiple properties with each their own variable can get a bit messy. Here’s a nice solution to store multiple properties in a single variable.
It just needs some color.
Well I ported the simplex noise to actionscript 3. The weird thing is that there is no speed increase whatsoever. I must be doing it wrong.
Just got back from a very relaxed vacation and I’m trying to pick up the old pace (but it’s too hot and humid here). Back at the old console I got this incoming link: Perlin Clouds and Frocessing (with an F). So somebody with a lot of spare time is porting Processing to AS3 (god knows why though, I can’t read Japanese). Very cool nonetheless.
Another little newsflash in that first post is that Mario Klingemann optimized my original Perlin Noise class. It’s now almost twice as fast! Funny how two simple things (type casting and unrolling functions) can have such a huge effect.
I originally created the class for use with something other that bitmaps, but since the speed increase allows it, Mario also implemented a bitmap fill method in there (although it doesn’t seem to have any scale control).
The long awaited version 2 alpha is out. Well it has been out for about two weeks but I haven’t had time to look into it. I’ve cooked up a little something to try it out together with some Filter Forge filters: check it out.
There are of course still some things that need to be fixed, but hey, it’s an alpha.
I don’t normally talk this type of geek talk but I just spent hours trying to debug the weirdest IE glitch.
When I code Flash I mostly always code positions relative to the stage dimensions (stage.stageWidth and stage.stageHeight). This prevents the trouble you go through when your client decides to add another x amount of pixels to the dimensions.
Now I only got this IE glitch online, and only on my Vista OS. XP was working fine for me, but on other machines XP did the same thing. That’s already quite random behavior but it probably has to do with the Flash plugin version.
The first time the page loads everything is fine. But if you reload, or navigate away and go back, both the stageWidth and the stageHeight are 0 on the first cycle. This is probably due to cashing and initializing but a Flash plugin bug nonetheless. A way to circumvene this problem is to run an enterframe and only startup the lot when the stageWidth and -Height are something else than 0. Or hardcode these values of course, but who would want that?
Hope this helps some desperate souls out there.
I have this attractor viewer written in Processing. I wanted to finish it up a bit: calculate Lyapunov exponent, save to movie, save online, etc. The problem is it’s written an older version of Processing. Then I thought: why not try as3 on for size. It’ll be faster for me to write since my Processing is getting a bit rusty. Well I got halfway and I’m going back to Processing for this. Just compare a million iterations in Processing to the same in as3. Processing kicks Flash’s ass! I just hope Processing has gotten a little better while I was away. I do hope I’ll be able to save movies.
When I started doing processing I fell in love with the Perlin noise function. A little while later Flash 8 came out including noise. But I was a bit disappointed in their noise implementation, since it was only (and still is) a BitmapData function (without falloff). Perlin noise can be used for much than just bitmaps. Of course you could just getpixel the generated noise data but that only gives you integer noise values.
So I did what I always wanted to do but never did (because I thought it would be too difficult): wrote a Perlin noise class. Actually I just ported the main part from Ken Perlin’s improved noise. But I still had to implement octaves, falloff and seed. The function now looks like Perlin.noise(x:Number,y:Number,z:Number):Number. I’d also like to insert a fourth dimension in there. So we would have three spacial- and one time dimension.
Flash does calculate it’s noise about a hundred times faster than this class does. So if you’re ok with integer input values for noise you might be better off getpixeling the noise data than using this class. But I don’t claim to be the god of code either; there is probably a lot that could be done to optimize this class. So if you have any suggestions please comment.
In the next example the bitmaps are created with the new noise function and setpixel. I’ve set the octaves horizontally and the falloff vertically. The first row has the same falloff as the second but a different seed for each bitmap. The x and y positions of the little ball are also controlled by Perlin noise with an octave of two and a falloff of one half. Click to view example
Here’s the download containing the above example. Things should become clear from the source code. If you still have any questions feel free to comment.
Here’s another example with multiple balls. Each cycle the balls gravity is calculated by feeding it’s position into the noise function. The collision in this example is managed by APE
There was a slight error in the falloff calculation. I’ve updated the download (version 1.2).