open Graphics2D let portal = {view=Some(vec2 0. 0., vec2 0. 0.); scene=Tiger.scene} let target = ref (bound_of portal.scene) let dt = dt() let paint() = match portal.view, !target with | Some (ol, ou), Some (nl, nu) -> let p = 0.1 ** dt() in portal.view <- Some (p *| ol +| (1. -. p) *| nl, p *| ou +| (1. -. p) *| nu) | None, target -> portal.view <- target | _ -> () let click = function | Some(i::_) -> (* If an object is clicked on then zoom to it. *) target := bound_of(get [i] portal.scene) | _ -> (* If the background is clicked on then zoom out to see the whole scene. *) target := bound_of portal.scene let () = let on_paint = Event.create() in Event.add paint on_paint; let on_click = Event.create() in Event.add click on_click; GUI.spawn ~on_paint ~on_click portal