Skip to content

Instantly share code, notes, and snippets.

@tai2
Created May 15, 2013 11:34
Show Gist options
  • Select an option

  • Save tai2/5583368 to your computer and use it in GitHub Desktop.

Select an option

Save tai2/5583368 to your computer and use it in GitHub Desktop.
Perlin noise test
float noise_step = 0.01;
float noise_velocity = 0.0001;
float noise_accel = 0.0001;
void setup() {
size(500, 500);
}
void keyPressed() {
if (keyCode == UP) {
noise_step += noise_velocity;
noise_velocity += noise_accel;
} else if (keyCode == DOWN) {
noise_step += noise_velocity;
noise_velocity -= noise_accel;
}
}
void keyReleased() {
if (keyCode == UP || keyCode == DOWN) {
noise_velocity = 0;
}
}
void draw() {
float ynoise = 0;
for (int y = 0; y < height; y++) {
ynoise += noise_step;
float xnoise = 0;
for (int x = 0; x < width; x++) {
xnoise += noise_step;
set(x, y, color(255 * noise(xnoise, ynoise)));
}
}
text("noise step=" + noise_step, 10, 10);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment