Javascript port of Patrick Coleman Saunders' Dot