function draw() {
  if (clearScreen) background(0, 0, 100);

  shapes.forEach(function(shape) {
    shape.draw();
    shape.update();
  });

  if (newShape) {
    newShape.addPos(mouseX, mouseY);
    newShape.draw();
    newShape.update();
  }
}
Drawing tool that moves a pendulum contraption along paths drawn by the mouse.
The last joint of the pendulum leaves behind its own trail.

MOUSE
mouse               : click and drag to create a path to draw a pendulum along with

KEYS
1                   : toggle path line
2                   : toggle pendulum
3                   : toggle pendulum path
4                   : toggle clear screen
-                   : decrease gravity
+                   : increase gravity
arrow down          : decrease length of lines
arrow up            : increase length of lines
arrow left          : decrease joints
arrow right         : increase joints
del, backspace      : clear screen
s                   : save png

CONTRIBUTED BY
[Niels Poldervaart](http://NielsPoldervaart.nl)