Skip to content

Instantly share code, notes, and snippets.

@alumican
Created May 5, 2014 05:02
Show Gist options
  • Save alumican/480af7ed67cd40cbb200 to your computer and use it in GitHub Desktop.
Save alumican/480af7ed67cd40cbb200 to your computer and use it in GitHub Desktop.
もじゃ
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;
}
@alumican
Copy link
Author

alumican commented May 5, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment