We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › using perlin noise
Page Index Toggle Pages: 1
using perlin noise (Read 785 times)
using perlin noise
Oct 30th, 2009, 3:17pm
 
I have a function say like so..


void update() {
 x = mouseX;
 y = mouseY;
 ellipse(x, y, 10, 10);
}

How do I incorporate perlin noise in it so that the ellipse start "swaying" from the starting point of (mouseX, mouseY)?

I tried the following but instead of starting at (mouseX, mouseY) it starts at another point. I know why, I just don't know how to do what I am wanting to do.

float inc = 0;
void update() {
 x = noise(inc) * mouseX;
 y = noise(inc+1) * mouseY;
 ellipse(x, y, 10, 10);
 inc += 0.01;
}
Re: using perlin noise
Reply #1 - Oct 31st, 2009, 12:38am
 
noise() gives values between 0 and 1, so you change dramatically the coordinates...
You can do something like:
x = mouseX + (0.5 - noise(inc)) * amountOfJitter;
where amountOfJitter is a constant, eg. 20 for a maximum of 10 pixels away from the mouse position.
Page Index Toggle Pages: 1