If you can generate an image you can flatten it and if you can flatten it you can cluster it, and if you can cluster the flat sections you can draw vectors around them.
This posterization-vectorization approach is what the Flash "Trace Bitmap" tool implemented (I'm not sure if Animate still has it?), but if your image isn't originally clipart/vector art, it gives the resulting vector art a very early 2000s look...