![]() |
![]() |
| Smoke Vector Graphics |
Tiger Demo
DescriptionThis demo renders a static predefined vector scene but registers a callback for the The result is a staggeringly impressive interactive demonstration of vector graphics that can be implemented in only 21 lines of OCaml code using our library. Moreover, performance far exceeds that of any other vector graphics renderers thanks to the use of advanced multiresolution techniques in the renderer. The entire program is as follows: open Graphics2D
let portal = {view=None; scene=Tiger.scene}
let target = ref (bound_of portal.scene)
Our library includes the definition of a useful function let dt = dt() The
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
| _ -> ()
The let click = function | Some(i::_) -> target := bound_of(get [i] portal.scene) | _ -> target := bound_of portal.scene The main program simply registers the callbacks and spawns a GUI: 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 CompilationThis example program may be compiled using our library with: $ ocamlopt -I +lablGL lablgl.cmxa lablglut.cmxa unix.cmxa graphics2D.cmxa tiger.ml -o tiger
(Note: We are not VAT registered and, therefore, cannot provide VAT receipts)
|
| © Flying Frog Consultancy Ltd., 2007 | Contact the webmaster |