sketch = function(p) {

  var nodeA, nodeB;
  var spring;

  p.setup = function() {
    p.createCanvas(p.windowWidth, p.windowHeight);
    p.noStroke();
    p.fill(0);

    nodeA = new Node(p.width / 2 + p.random(-50, 50), p.height / 2 + p.random(-50, 50));
    nodeB = new Node(p.width / 2 + p.random(-50, 50), p.height / 2 + p.random(-50, 50));

    nodeA.damping = 0.1;
    nodeB.damping = 0.1;

    spring = new Spring(nodeA, nodeB);
    spring.length = 100;
    spring.stiffness = 0.6;
    spring.damping = 0.3;
  };

  p.draw = function() {
    p.background(255);

    if (p.mouseIsPressed == true) {
      nodeA.x = p.mouseX;
      nodeA.y = p.mouseY;
    }

    // update spring
    spring.update();

    // update node positions
    nodeA.update();
    nodeB.update();

    // draw spring
    p.stroke(0, 130, 164);
    p.strokeWeight(4);
    p.line(nodeA.x, nodeA.y, nodeB.x, nodeB.y);

    // draw nodes
    p.noStroke();
    p.fill(0);
    p.ellipse(nodeA.x, nodeA.y, 20, 20);
    p.ellipse(nodeB.x, nodeB.y, 20, 20);
  };

  p.keyPressed = function() {
    if (p.key == 's' || p.key == 'S') p.saveCanvas(gd.timestamp(), 'png');
  };

}
two nodes and a spring

MOUSE
click, drag   : postion of one of the nodes

KEYS
s             : save png