Nails are spaced evenly around a circle placed over the photo. The thread starts at nail 0. At each step, the program tests a straight line from the current nail to every other nail. It picks the line that crosses the darkest part of the photo, lightens those pixels in its working copy of the photo, and moves to the chosen nail. It repeats this for the chosen number of lines.
Nails are numbered from 0, counter-clockwise, starting at the 3 o’clock position. Lines between nails that are close together are skipped, so the thread does not run along the edge of the circle.
Source code: github.com/addisonkopplin/string_art