Skip to content

Refactor interpolation methods

I've refactored the interface for interpolation methods, cleaning up the spaghetti code in interp.py and interp-att-g.py. The idea is as follows: There are a multitude of derived classes from AttributeInterpolator, which have to define interpolate(self, time=0). They may also define a custom initializer. Types of interpolators are e.g. ColorInterpolator, LinearGradientInterpolator, PathInterpolator, UnitValueInterpolator and so on. If you don't know which interpolator to use, just call AttributeInterpolator.create(snode, enode, path, svg) which deals with the rest.

The interface added by !183 (closed) (style.interpolate(other, time)) still exists but defers to the new classes.

This makes the interpolation in interp.py and interp-att-g.py increadibly easy.

Also about half of the lines in this MR are comments. I tried to reverse-engineer some of the path interpolation methods.

Edited by Jonathan Neuhauser

Merge request reports