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
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