反转整数值

发布于 2024-09-18 20:46:57 字数 239 浏览 0 评论 0原文

我有一个场景,我想我可以通过 PC Monitor 的例子来传达(虽然不是真实的)。

假设我有两台分辨率和属性不同的显示器。一台显示器在屏幕上从上 (0) 到下(最大值)绘制鼠标光标,另一台显示器从下 (0) 到上(最大值)绘制鼠标光标。换句话说,在绘制鼠标光标时,两者都有彼此相反的 y 轴,我需要编写一个公式,将一个显示器光标位置转换为另一个显示器光标位置,给定一个显示器 x 和 y 光标位置,反之亦然。

什么公式最适合这个?

I have a scenario which I think I can convey giving PC Monitor example (not real though).

Assume I have two monitors both of different resolution and properties. One monitor draws mouse cursor on screen from top (0) to bottom (max-value) and other draws mouse from bottom (0) to top (max-value). In other words both have reverse y-axis of each other in drawing mouse cursor and I need to write a formula that will convert one monitor cursor position to another and vice versa given one monitor x and y cursor positions.

What formula is the best suited for this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

李白 2024-09-25 20:46:57
right_x = (1 - left_x / left_width) * right_width
right_y = (1 - left_y / left_height) * right_height

需要知道 left_xleft_y(以及每个显示器的分辨率)。

right_x = (1 - left_x / left_width) * right_width
right_y = (1 - left_y / left_height) * right_height

The left_x and left_y (as well as the resolutions for each display) would need to be known.

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