开发者

how do I measure the stroke angle?

开发者 https://www.devze.com 2022-12-25 12:37 出处:网络
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 o

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号