C# 中 2D 图形的多重 GDI 转换

发布于 2024-11-05 16:21:25 字数 419 浏览 0 评论 0原文

我正在编写一个图形应用程序,可以使用鼠标控制执行全局转换(旋转和平移)。有谁有一个示例展示如何使用以下方法实现此目的:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

很糊涂小朋友 2024-11-12 16:21:25

请记住,MouseDown 只能进行一次。我认为在 MouseDown 事件中,除了设置偏移量之外,您还需要对其进行转换。而且您可能还需要一个变量

bool isMouseDown = true;

来帮助 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

bool isMouseDown = true;

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文