Hello!
I’m playing with randomGaussians, and gradual transitions, trying to understand the concept, and I’ve hit a bit of a snag.
I’m hoping someone can help with the math involved.
I’m drawing simple squares in a grid pattern. I’d like the left side of the grid to be… “normal.”
All the squares are drawn as they should be, in a simple grid.
But as we get to the right side of the grid, I’d like square placement to become more “crazy.”
So this is what I’ve got so far.
size(800, 400);
int scale = 10;
background(0);
noStroke();
rectMode(CENTER);
for (int x = 0; x <= width; x += scale) {
for (int y = 0; y <= height; y += scale) {
float pDistribution = map(x, 0, width, 0, 15);
float xDrift = randomGaussian() * pDistribution;
float yDrift = randomGaussian() * pDistribution;
fill(200);
push();
translate(x, y);
rect(xDrift, yDrift, scale, scale);
pop();
}
}
I’m proud of getting this far, because it’s doing essentially what I want.
The only thing is, I’d like the Gaussian Distribution to have a more exponential curve.
Hopefully, I’m using the correct terminology here.
Basically, I’d like the squares to be in their more “correct” spots a bit longer longer as we travel across x.
The squares on the far left and far right are exactly where I want them, but I’d like the middle to chill out a bit.
Because of the word “exponential”, I thought maybe exp()
should go in there somewhere, but I don’t really understand how it would fit.
If I need to rephrase or clarify what I’m asking, please let me know!
Any advice would be greatly appreciated!