let over_selector = fun (button:int array) (x:int) (y:int) ->
let dx = x - button.(0)
and dy = y - button.(1)
and small_radius = button.(2)
and radius = button.(3)
and n = button.(4)
and selection = button.(5) in
let ddx = float dx
and ddy = float dy
and nn = pred n in
let distance = dx * dx + dy * dy in
if distance <= small_radius * small_radius then
begin
if dx > 0 then
min ( succ selection ) nn
else
max 0 ( pred selection )
end
else
if distance <= radius * radius then
let angle = positive_argument ( -. ddy ) ( -. ddx )
and sector = Infinitesimal.pi /. ( 1. +. ( float n ) ) in
let position = floor ( angle /. sector ) in
min nn ( ( ( int_of_float position ) - 1 ) / 2 )
else selection