00:00
00:00
Newgrounds Background Image Theme

squirrelysteve just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

Gravity Fractal

Share

PICO-8 tweetcart.

The blue lines indicate the trajectory of simulated particles as they are pulled by the planets' gravity. If a particle hits a planet (one of the colored outlines) it colors its originating pixel the color of that planet. If a particle doesn't hit a planet within a certain number of steps in the simulation, it colors the originating pixel black.


This tweetcart is inspired by a video about fractal patterns that emerge from gravity simulations:


The full source code for the effect can be viewed below. Run/edit the code in PICO-8 here!

for r=0,8192do
x=r%128y=r\128u=0v=0i,o=x,y
for k=1,128do
for j=0,4do
srand(j+9)g=rnd(128)h=rnd(128)q=x-g
w=y-h
d=((q/4)^2+(w/4)^2)^█*16u-=q/d
v-=w/d
circ(g,h,2,j+8)if(d<15)sset(i,o,j+8)goto l
end
line(x,y,x+u,y+v,1)x+=u
y+=v
end
::l::if(stat(1)>.8)flip()
memcpy(24576,0,8192)end

For the sake of performance, I had very few steps in the simulation per pixel, leading to a stripey/paint splatter effect seen in the final result. You can try to change some of the variables to improve the resolution of the simulation!

Log in / sign up to vote & review!

Credits & Info

Artist
Views
32
Faves:
2
Score
Waiting for 2 more votes

Uploaded
Aug 30, 2024
1:00 PM EDT
Category
Other

You might also enjoy...

Licensing Terms

You may not use this work for any purposes.