Mobile touch/swipe: Angle snapping 0, 90, 180, 270, possible?

Hi! As the topic implies, I am searching for a way to snap mobile touch Enter input to 0/90/180/270 angles. Anyone knows how I can achieve this?
Specifically, I am making a game where the user draws on the screen, but I need the user input to be limited to the straight lines (because the user never draws entirely straight lines), so that it still follows the first coordinate path, until the angle is 90 degrees or more, then it changes direction. Any guidance much appreciated.