FWIW, py5 makes it very easy to create animated GIFs. You can create a GIF from a running sketch with one line of code:
https://py5coding.org/reference/py5tools_animated_gif.html
py5 is a version of Processing for Python 3.8+ that is well integrated into the Python ecosystem. It connects the Processing Jars to Python using JPype. If you like Processing, please give it a try!
(I am the author of py5)