Created
May 15, 2013 11:34
-
-
Save tai2/5583368 to your computer and use it in GitHub Desktop.
Perlin noise test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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