Skip to main content

detect_quadrant

Function detect_quadrant 

Source
pub fn detect_quadrant(
    cursor_col: u16,
    cursor_row: u16,
    target: &LayoutRect,
) -> Quadrant
Expand description

Determine which diagonal quadrant of target the cursor falls in.

Uses dimension-scaled cross-product (no floating-point, no sqrt) to account for the target’s aspect ratio. The comparison |dx| * height > |dy| * width is equivalent to checking whether the angle from center to cursor is shallower than the true geometric diagonal (±height/±width), producing equal-area triangular quadrants regardless of the rectangle’s shape.