Look at the algorithm of this page because it contains the source code from which it was derived.
Here is my summary of what the functions do:
addmove: first, it decides whether the mouse / pointer moved far enough to read the new position for writing. If he has, then he determines which of the eight directions the movement is in, and adds it to the list of moves.
costLeven: calculates the Levenshtein distance between two sequences. In this case, it is used to measure the distance between each predefined gesture sequence and the user-entered gesture sequence. It is mainly used to determine which letter is the best choice for output based on an input gesture. A small Levenshtein distance indicates a better match.
matchGesture (closest to meatureGesture): accepts a user-entered gesture and checks it on all predefined gestures to find the best match based on Levenshtein distance. If there is a close enough match, then the key with a pre-agreed gesture is passed to onGestureListener.onGesture (), which causes some actions. In this case, the letter is displayed on the screen.
source share