how do I measure the stroke angle?
I am working on wpf project, I want to know how to measure the angle of the stroke on the ink canvas? whether the stroke is right i开发者_Python百科nclined or left inclined?
When you get a mouse down on the canvas, save away the current mouse position. Later, when you receive a mouse up event, you know the stroke is finished. Get the mouse position a second time and calculate the difference between the second position and the first position. Then you just have some simple math to do, and there are a couple cases to consider.
Note that this will not work so well for complex, curved strokes (because you will only receive a mouse-up event at the end of the stroke). This will work best in the case of single, straight lines.
精彩评论