Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function to rotate pixel #417

Open
MarcelRobitaille opened this issue Mar 1, 2023 · 0 comments
Open

Add function to rotate pixel #417

MarcelRobitaille opened this issue Mar 1, 2023 · 0 comments

Comments

@MarcelRobitaille
Copy link
Contributor

This code to rotate a pixel from the virtual, rotated coordinate to physical screen coordinates is repeated many times.

int16_t t;
switch (rotation) {
case 1:
  t = x;
  x = WIDTH - 1 - y;
  y = t;
  break;
case 2:
  x = WIDTH - 1 - x;
  y = HEIGHT - 1 - y;
  break;
case 3:
  t = x;
  x = y;
  y = HEIGHT - 1 - t;
  break;
}

I think there should be a function applyRotation(x, y) that goes from virtual, rotated coordinates to physical screen coordinates. I think there should also be a function that does the inverse. Something like undoRotation(x, y) that goes from physical screen coordinates to virtual, rotated coordinates. This is useful when using touch screens, so you can transform the touch event's coordinates into the virtual coordinates.

Would you accept a pull request generalizing all of the places this code is repeated into a single function and adding the inverse function?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant