I'm writing a simple SVG drawing app, now i'm trying to optimize line drawing. The raw variant is draw every 'lineTo' on every mousemove event. It creates bad looking sharpness.
Im using global variable testInt to simulate delay between lineTo's actions, it gives really nice smooth line, but seems like bad practise. Could anyone suggest a better solution?
Here's my drawLine function code (as i said it basically modifies existing < path > element):
drawLine: function(id, X, Y){
var path = document.getElementById(id);
if(path.getAttribute('d'))
{
testInt++;
if(testInt>=6)
{
PathHelper.addLineTo(path, X, Y);
testInt = 0;
}
}
else
{
PathHelper.moveTo(path, X, Y);
}
}
PathHelper is only generates the right string and inserts it in already created path.