gui.add( params, 'distance', 5, 200 );
gui.add( params, 'tightness', 0.001, 0.5).step(0.025).onChange(function(){
spline.setTightness( params.tightness );
});
gui.add({
clear: function(){ ctx.clearRect(0,0,canvas.width,canvas.height); }
}, 'clear');
window.onmousemove = function(e){
update(e.pageX,e.pageY);
};
}
function update(mouseX,mouseY){
var numP=points.length;
var currP=new toxi.geom.Vec2D(mouseX,mouseY);
if (numP>0) {
var prevP=points[numP-1];
if (currP.distanceTo(prevP)> params.distance) {
points.push(currP);
ctx.strokeStyle = "rgba(0,0,0,0.5)";
ctx.beginPath();
ctx.arc(currP.x,currP.y,3,0,Math.PI*2);
ctx.stroke();
ctx.closePath();
spline.add(currP);
if (numP > 1) {
var lastP = points[numP-2];
var p = points[numP-1];
line(lastP.x,lastP.y,p.x,p.y);
ctx.strokeStyle = "rgba(0,0,0,0.5)";
ctx.arc(p.x,p.y,7,0,Math.PI*2);
}