PDA

View Full Version : Lava Lamp



rjp74
23-09-2012, 18:09
I searched in vain for perlin noise implemented in ThinBasic. So decided to create something similar, based on random numbers, but easily controllable. I came up with the idea of a sparse array with some randoms numbers and a second detail array which interpolates over the random numbers using cosine interpretation to ensure smooth transitions. I had to precompile the cosine values and the hues to get some performance improvement. I did try and convert it to Oxygen but I couldn't work out how to pass two dimensional arrays. But the code runs reasonably "as is" on my 5 year old laptop.

I am using the basic smoothed set of random numbers to create the image. I then evolve the array by a set of small delta random numbers which shifts the values in a controlled way. I then take a small percentage of the base random numbers set and add them to the row above to create the "rising" effect. I am using random numbers, but you can put anything into the base array. If the regular coordinates is a concern, you can still use this approach and then apply a transformation to get the final shape you desire. e.g. rectangular to polar coordinates.

And yes I know it does not look like a lava lamp but I didn't think of a better description right now.

7966

and the code is here:
7967

kryton9
23-09-2012, 21:30
Lava lamp is a good name as it is mesmerizing to watch. Great job!

omarpta
24-09-2012, 15:06
Great! Its wonderful.

ErosOlmi
24-09-2012, 21:02
Yes, really great.
Thanks for sharing it

Still trying to understand how it works but .... This is my lack of knowledge on the specific matter :cry: