pasted source code from svg.py (branch=testing)