Skip to content

Instantly share code, notes, and snippets.

@sasaki-shigeo
Last active December 12, 2016 17:16
Show Gist options
  • Save sasaki-shigeo/7744423 to your computer and use it in GitHub Desktop.
Save sasaki-shigeo/7744423 to your computer and use it in GitHub Desktop.
Demonstration of snow falling (the number of crystals is fixed) /雪の降下アニメーション (雪の結晶の個数固定)
class Crystal {
float x, y, phi;
Crystal(float x0, float y0, float phi0) {
x = x0;
y = y0;
phi = phi0;
}
void fall() {
y += 1;
}
void show() {
noStroke();
ellipse(x, y, phi, phi);
}
}
Crystal[] crystals = new Crystal[100];
void setup() {
size(500, 500);
for (int i = 0; i < crystals.length; i++) {
crystals[i] = new Crystal(random(width), random(height), 20);
}
}
void draw() {
background(180);
for (int i = 0; i < crystals.length; i++) {
crystals[i].fall();
crystals[i].show();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment