Radial Menu Math
Core mathematical functions for RadialMenu positioning and selection.
These functions are public to allow developers building custom RadialMenu implementations to reuse the positioning algorithms.
The key algorithm is calculateCenterAngle which ensures menu items never appear off-screen regardless of where the user touches.
Since
1.0.0
Functions
Link copied to clipboard
Link copied to clipboard
fun detectZone(x: Float, y: Float, screenWidth: Float, screenHeight: Float, edgeThreshPx: Float): RadialMenuMath.MenuZone
Detects which screen zone the touch point falls in.
Link copied to clipboard
fun edgeHugLayout(zone: RadialMenuMath.MenuZone, screenWidth: Float, screenHeight: Float, itemCount: Int, itemSizePx: Float, gapPx: Float, padPx: Float): List<Offset>
Computes item center positions for the edge-hug L-shaped layout.
Link copied to clipboard
Link copied to clipboard
fun getSelectionFromDrag(dragX: Float, dragY: Float, centerAngle: Float, itemCount: Int, spreadDegrees: Float = RadialMenuDefaults.ICON_SPREAD_DEGREES, deadZonePx: Float = RadialMenuDefaults.DEAD_ZONE_PX, selectionDeadZoneDeg: Float = RadialMenuDefaults.SELECTION_DEAD_ZONE_DEG): Int?
Determines which item index the user is dragging toward.
Link copied to clipboard
Normalizes any angle to the 0 to 360 degree range.