Created
May 5, 2014 05:02
-
-
Save alumican/480af7ed67cd40cbb200 to your computer and use it in GitHub Desktop.
もじゃ
This file contains 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 offsetX; | |
float offsetY; | |
float endY; | |
float posX; | |
float posY; | |
float oldX; | |
float oldY; | |
float noise = 0; | |
void setup() { | |
size(800, 800); | |
background(255, 255, 255); | |
reset(); | |
} | |
void draw() { | |
for (int i = 0; i < 100; i++) { | |
drawLine(); | |
} | |
} | |
void reset() { | |
posX = oldX = 0; | |
posY = oldY = 0; | |
offsetX = 0.5 + random(-1, 1) * 0.1; | |
offsetY = random(0, 0.3); | |
endY = min(1, offsetY + random(0.1, 1)); | |
} | |
void drawLine() { | |
float ratio = map(offsetY / endY, 0, 1, 0.5, 1); | |
posX += 0.005 * ratio * (noise(noise) - 0.5); | |
posY += 0.005 * ratio * (noise(noise + 1000) - 0.5); | |
line((oldX + offsetX) * width, (oldY + offsetY) * height, (posX + offsetX) * width, (posY + offsetY) * height); | |
if (offsetY >= endY) { | |
reset(); | |
} | |
offsetY += 0.001; | |
oldX = posX; | |
oldY = posY; | |
noise += 0.01; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run on http://www.processing.org/