Convex hull of a set of points

Below, you will find a canvas. Clicking inside the canvas will add points. Once there are three or more points, the convex hull of the points will be computed and drawn.

Note that the hull is recomputed entirely for each new point added afterwards (you will probably not click sufficiently many times for the computation to be very slow).

The algorithm used to compute the convex hull is the Graham scan. The code included in this page is released into the public domain.