Curved text using SVG2

the polyline traced by the user is interpolated/resampled, and becomes path for the SVG text element.

HTML

<script src="https://s3-eu-west-1.amazonaws.com/svgjs/svg.draggable.js"></script>
<script src="https://s3-eu-west-1.amazonaws.com/svgjs/svg.clock.js"></script>
<script src="https://s3-eu-west-1.amazonaws.com/svgjs/svg.import.js"></script>
<script src="https://s3-eu-west-1.amazonaws.com/svgjs/svg.filter.js"></script>
<script src="https://s3-eu-west-1.amazonaws.com/svgjs/svg.export.js"></script>
<script src="https://s3-eu-west-1.amazonaws.com/svgjs/svg.easing.js"></script>
<script src="https://s3-eu-west-1.amazonaws.com/svgjs/svg.shapes.js"></script>
<script src="https://s3-eu-west-1.amazonaws.com/svgjs/svg.topath.js"></script>
<script src="https://s3-eu-west-1.amazonaws.com/svgjs/svg.parser.js"></script>
<h1>Instructions</h1>
<ol>
    <li>Enter some text</li>
    <li>Trace a path in the canvas (mouse down to begin path, mouse up to end path)</li>
</ol>
<div id="drawing" style="border:1px solid black; width:300px; height:300px"></div>
<br/>
<input id="input" type="text" size="45" placeholder="enter some text"></input>
<br/>
<button id="animateButton">Begin Animation</button>
<label>FPS: </label>
<span id="fps"></span>
<div id="output"></div>

JavaScript

/* create an svg drawing */
var draw = SVG('drawing')
var path = null;
var polyline = null;
var text = 'Hello World!';
var button = document.getElementById('animateButton');
var animationId = null;
var intervalId = null;
var fps = 0;
var animate = true;
var animationStep = 5.0;
var rotation = 0;
button.addEventListener('click', animateHandler, false);
draw.on('mousedown', mousedown);

function mousedown(e)
{
    rotation = 0;
    draw.clear();
    stopAnimation();    
    var p = getCursorPosition(e);
    path = [];
    path.push([p.x, p.y]);
    draw.on('mousemove', mousemove);
    draw.on('mouseup', mouseup);    
}

function mousemove(e)
{
    var p = getCursorPosition(e);
    path.push([p.x, p.y]);    
    update();
}

function mouseup(e)
{
    draw.off('mousemove', mousemove);
    draw.off('mouseup', mouseup);
    drawText();
}

function updateFps(time)
{
    document.getElementById('fps').innerHTML = fps;
    fps = 0;
}

function animateFrame(time)
{
    rotation += animationStep;
    draw.each(function(i, children) {
        children[i].transform({rotation: rotation});
    });
    fps++;
    animationId = requestAnimationFrame(animateFrame);
}

function animateHandler()
{    
    if (animate)
    {
        animate = false;
        button.innerHTML = 'Stop Animation';                   
        animationId = requestAnimationFrame(animateFrame);        
        intervalId = setInterval(updateFps, 1000);
    }
    else
    {
        animate = true;
        stopAnimation();
    }
}

function stopAnimation()
{
    if (animationId)
    {        
        window.cancelAnimationFrame(animationId);
        animationId = null;            
    }    
    if (intervalId)
    {
        clearInterval(intervalId);
        intervalId = 0;
        fps = 0;
    }   
    
    button.innerHTML = 'Begin Animation';
}


function update()
{    
    polyline && polyline.remove();    
    polyline = draw.polyline(path).fill('none').stroke({width:1});
}

function drawText()
{
    var...