We are about to switch to a new forum software. Until then we have removed the registration on this forum.
float power;
float d;
void setup(){
size(600, 600);
background(184, 143, 80);
power = 3; // turbulence power
d = 12; // turbulence density
noStroke();
frameRate(3);
}
void draw(){
for(int y = 0; y < height; y++){
for(int x = 0; x < width; x++){
float total = 0;
for(float i = d; i >= 1; i = i/2){
total += noise(x/d, y/d) * d;
}
float turbulence = 128 * total / d;
float base = (x * 0.2) + (y * 0.12);
float offset = base + (power * turbulence / 256);
float gray = abs(sin(offset)) * 256;
stroke(gray, 100);
point(x, y);
}
}
d++;
if(d > 128){
d = 0;
}
}
I found this on page 132 of "Processing: a handbook for visual designers and artists" and make a little modification to make it "move".
Question is I don't understand the algorithm here. This program generates something like this:
Answers
"What's this "diverse texture" piece of code all about?"
It is about making a texture, as you found out as you show an image of the result...
For the algorithm, search the Net about Perlin noise. Starting point: noise()
I am studying the Processing Handbook (2nd edition), and also been stuck in the same example (p. 324, ex. 21_17). So far, every example was comprehensible till this one.
Any hints for where to search for Perlin noise, that does not require too advanced math or another computer language?
Thanks