C# 中 2D 图形的多重 GDI 转换
我正在编写一个图形应用程序,可以使用鼠标控制执行全局转换(旋转和平移)。有谁有一个示例展示如何使用以下方法实现此目的:
MouseDown(object sender, MouseEventArgs e) - set the translate/rotate offset
MouseMove(object sender, MouseEventArgs e) - increment translate/rotate variables
OnPaint(Graphics graphics, float time) - use Matrix object to do global transform
问题:旋转图形后,当我平移它们时,它们会根据旋转变换移动。我是否需要在设置翻译变量的 MouseDown 和 MouseMove 中补偿这种旋转?
I'm writing a graphics app that can perform global transformations (rotate and translate) using mouse control. Does anyone have a sample showing how to implement this with the following methods:
MouseDown(object sender, MouseEventArgs e) - set the translate/rotate offset
MouseMove(object sender, MouseEventArgs e) - increment translate/rotate variables
OnPaint(Graphics graphics, float time) - use Matrix object to do global transform
The problem: after rotating the graphics, when i then translate them they move according to the rotate transform. Do I need to compensate for this rotation in MouseDown and MouseMove where I'm setting the translate variable?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请记住,MouseDown 只能进行一次。我认为在 MouseDown 事件中,除了设置偏移量之外,您还需要对其进行转换。而且您可能还需要一个变量
来帮助 MouseMove 指示它处于“mouseDown 之后”状态。
在MouseMove事件中,基本上你正在做与MouseDown事件中相同的过程,区别只是鼠标的坐标。
Remember, MouseDown is only proceed once. I think in the MouseDown event, beside setting the offset you need to transform it. And also you need a variable perhaps
to help MouseMove indicate that it is in "after mouseDown" state.
And in the MouseMove event, basically you are doing the same process as in the MouseDown event, the diffrerence is only the coordinate of the mouse.