Skip to content

Captures a list of points which typically represents a mouse path which is decoded as a stroke or gesture.

License

Notifications You must be signed in to change notification settings

TonyReinberger/Stroke

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stroke

Captures a list of points which typically represents a mouse path which is decoded as a stroke or gesture.

I was working at a company in early 2000, using Mentor Graphics CAD tools which implement middle button mouse gestures as shortcuts to commands. While dabbling in Objective-C, I tried implementing the equivalent functionality in an example sketch program provided by Apple. It worked but the code / algorithm sat unused for many many years. Recently I've been writing some tools in Python and I wanted to share the algorithm since I think it was clever. I translated it to Python and used wxPython libraries to create a graphical demo.

stroke_demo.py will let you practice using strokes / gestures using the left mouse button and drawing in the window. wxPython does not currently work with Python 3.10 so you should use 3.9 for now to run the demo.

stroke.py implements an algorithm which translates the path (points) on a virtual grid into a unique identifier. This can be translated to other languages. I purposely changed it some so that it could be implemented in C with only integers and not use any division provided you remove the debug grid code. I recently changed it to return an integer which is faster to execute and use in other languages such as C. You might want to use 64 bit integers and stop if it overflows. 32 bits however will store most gestures.

stroke_decode.py contains a function which will turn the number sequence into some descriptive text. This was added because the numbers are not so descriptive.

Below are a couple of screenshots from the demo. The path is displayed as a thick black line. White dots show the points captured by the mouse move event handler and a red grid is overlaid to show the extents of the path to understand the decoded value.

Screen Shot 2022-01-25 at 2 16 04 AM Screen Shot 2022-01-25 at 2 17 27 AM Screen Shot 2022-01-25 at 2 21 23 AM

I'll be back here to improve the readme and wiki since this is my first github repository.

About

Captures a list of points which typically represents a mouse path which is decoded as a stroke or gesture.

Topics

Resources

License

Stars

Watchers

Forks

Languages