00:00
00:00
Newgrounds Background Image Theme
Upgrade Your Account!

HO HO HOPE you become a Newgrounds Supporter this year!

We're working hard to give you the best site possible, but we have bills to pay and community support is vital to keep things going and growing. Thank you for considering!

Become a Supporter so NG can see another Christmas!

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

Views
44
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.