Minor refactor in CurveWidget drawing

This was mostly done because flake8 was complaining a lot about how
previously variables were technically used before they existed. In
practice, this wouldn't happen, but I thought the code should have a
minor rework anyway.