Simple fractal using circles spheres var canvas document createElement canvas document body appendChild canvas canvas width canvas height 512 var context canvas getContext 2d Define the circle parameters var centerX canvas width 2 var centerY canvas height 2 const ellipse centerX centerY radius Begin the path for the circle context beginPath context arc centerX centerY radius 0 5 0 2 Math PI false Fill the circle with color context fillStyle rgba 128 0 0 0 5 context fill Stroke the circle s outline context lineWidth 2 context strokeStyle black context stroke ellipse 10 10 5 const holocrux x y s if s 20 return ellipse x y s smaller inside the main circle holocrux x s 3 y s 3 holocrux x s 3 y s 3 holocrux x y s 3 s 3 holocrux x y s 3 s 3 smaller outside the main circle holocrux x 2 s 3 y s 3 holocrux x 2 s 3 y s 3 holocrux x y 2 s 3 s 3 holocrux x y 2 s 3 s 3 holocrux 250 250 200
circle s outline context lineWidth 2 context strokeStyle black context stroke ellipse 10 10 5 const holocrux x y s if s 20 return ellipse x y s smaller inside the main circle holocrux x s 3 y s 3 holocrux x s 3 y s 3 holocrux x y s 3 s 3 holocrux x y s 3 s 3 smaller outside the main circle holocrux x 2 s 3 y s 3 holocrux x 2 s 3 y s 3 holocrux x y 2 s 3 s 3 holocrux x y 2 s 3 s 3 holocrux 250 250 200