Skip to content

Instantly share code, notes, and snippets.

@sasaki-shigeo
Created December 25, 2025 03:09
Show Gist options
  • Select an option

  • Save sasaki-shigeo/a47dd12d08bacefe22bc4ba2a138dcf6 to your computer and use it in GitHub Desktop.

Select an option

Save sasaki-shigeo/a47dd12d08bacefe22bc4ba2a138dcf6 to your computer and use it in GitHub Desktop.
class Star {
float x, y, r;
int time;
Star(float x0, float y0, float sz, int t0) {
this.x = x0;
this.y = y0;
this.r = sz/2;
this.time = t0;
}
Star(float x0, float y0) {
this(x0, y0, 30, int(random(1200)));
}
void show() {
if ((time + frameCount) % 1200 < 30) {
return;
}
push();
noStroke();
fill(#FFFF00);
translate(this.x, this.y);
rotate(radians(-90));
beginShape();
for (int i = 0; i < 5; i++) {
vertex(r * cos(radians(144 * i)),
r * sin(radians(144 * i)));
}
endShape(CLOSE);
pop();
}
}
class Crystal {
float x, y, r;
Crystal(float x0, float y0, float sz) {
this.x = x0;
this.y = y0;
this.r = sz/2;
}
void fall() {
y += 0.5;
if (y > height) {
x = random(width);
y = 0;
}
}
void show() {
push();
translate(x, y);
rotate(radians(-90));
stroke(#FFFFFF);
strokeWeight(2);
for (int i = 0; i < 6; i++) {
line(0, 0, r * cos(radians(60 * i)), r * sin(radians(60 * i)));
}
pop();
}
}
Star[] stars = new Star[30];
Crystal[] snow = new Crystal[100];
void setup() {
size(500, 500);
for (int i = 0; i < 30; i++) {
stars[i] = new Star(random(width), random(height));
}
for (int i = 0; i < 100; i++) {
snow[i] = new Crystal(random(width), random(height), 15);
}
}
void draw() {
background(#0000CC);
for (Star s: stars) {
s.show();
}
for (Crystal c: snow) {
c.show();
c.fall();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment