calculateCenterAngle

fun calculateCenterAngle(x: Float, y: Float, screenWidth: Float, screenHeight: Float, isRtl: Boolean = false): Float(source)

Calculates the optimal center angle for the radial menu fan based on touch position, ensuring items always appear on-screen.

When the touch is in the lower ~70% of the screen, the fan points upward (away from the finger). When near the top edge, the fan flips downward so items don't clip off-screen.

Horizontal edge-boost tilts items away from the nearest screen edge.

Return

Angle in degrees (0 = right, 90 = down, 180 = left, 270 = up).

Parameters

x

Touch X position in pixels.

y

Touch Y position in pixels.

screenWidth

Screen/container width in pixels.

screenHeight

Screen/container height in pixels.

isRtl

Whether the layout direction is right-to-left.