Reverse Integer Values
-
02-10-2019 - |
Pergunta
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?
Solução
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.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow