Skip to content

Instantly share code, notes, and snippets.

@volfegan
Created February 5, 2020 04:07
Show Gist options
  • Save volfegan/9a5fb7f8affcedcefc831c9b95f59510 to your computer and use it in GitHub Desktop.
Save volfegan/9a5fb7f8affcedcefc831c9b95f59510 to your computer and use it in GitHub Desktop.
Java port from Kahrzdn Javascript version of a snow globe shaking and snowing.
//https://twitter.com/Kahrzdn/status/1224791864940908546
float c=0, d, y, W=720;
void setup() {
size(720, 720);
}
void draw() {
fill(0);
if (c++%W<40) d=c*W%57;
else d = 0;
circle(W/2, W/2+d, W);
float b=630+d;
rect(120, b, 480, W);
noStroke();
for (float i=0; i<W; i++) {
y=min(b-4, c%W*i/W+noise(c/W+i/10)*W*2-W/2)+d;
float x=99*i%W+sin(y/20)*i/50;
fill(i/2, 230);
if (dist(x, y, W/2, W/2) < W/2)
circle(x, y, i/50);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment