getCursorPosition method

Vector2 getCursorPosition(
  1. double cursorX,
  2. double cursorY
)
  • Calculate the cursor position inside the canvas x/y coordinates with the origin being in the center of the canvas
  • cursorX Cursor horizontal coordinate within the canvas
  • cursorY Cursor vertical coordinate within the canvas
  • returns Vector2 Cursor position inside the canvas

Implementation

Vector2 getCursorPosition(double cursorX, double cursorY) {
    _v2_1.setFrom(getCursorNDC(cursorX, cursorY));
    _v2_1.x *= (camera.right - camera.left) * 0.5;
    _v2_1.y *= (camera.top - camera.bottom) * 0.5;
    return _v2_1.clone();
  }