Also, just an additional question while I'm here:
If I decided that I want to take THIS code and compile it into an API. Do you think it would be better to use UI?
And if so, do you think turning it into a UI will be easy when I'm done or is it better to start over and write the code as a UI.

@Pythonistapro777 , I am really bad at this sort of stuff. But I a, pretty sure you after ui.Path and its associated methods for drawing shapes, lines etc. if you search ui.Path in docs, all the class methods are underneath. This is what you use in ui. I am pretty sure the same is used in scene