detection of the nearest point drawn