Here is one approach.
import os
import math
nfigs = 20
HOME = os.getenv('HOME')
pathdir = os.path.join(HOME, 'test')
if not os.path.exists(pathdir):
os.mkdir(pathdir)
canvas_height, canvas_width = 500, 500
cx, cy = canvas_height / 2, canvas_width / 2
r1, r2 = 200, 20
# A list of angles to rotate the small red circle through:
alphas = [2*math.pi / nfigs * n for n in range(nfigs)]
for n, alpha in enumerate(alphas):
filename = os.path.join(pathdir, 'fig{:02d}.svg'.format(n))
with open(filename, 'w') as fo:
# SVG preamble
print("""<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
width="{}" height="{}" style="background: {}">""".format(
canvas_width, canvas_height, '#ffffff'), file=fo)
# Large, open black circle
print('<circle cx="{}" cy="{}" r="{}" style="stroke: black;'
' stroke-width: 2px; fill: none;"/>'.format(cx, cy, r1),file=fo)
# Small, filled red circle on the inner rim of the black one,
# displaced from the x-axis by the angle alpha
cx2, cy2 = cx+(r1-r2) * math.cos(alpha), cy+(r1-r2) * math.sin(alpha)
print('<circle cx="{}" cy="{}" r="{}" style="stroke: red; fill: red;"/>'
.format(cx2, cy2, r2), file=fo)
print('</svg>', file=fo)
Running these files through ImageMagick's convert
program as suggested generates the animate GIF below.