Pick one of 16 cases from the four corners' above-threshold bits and find the edge points by linear interpolation — the result is a smooth closed contour, with balls merging and splitting as they move

5balls · marching squares contour canvas · getImageData · Path2D · quadraticCurveTo