Parcourir la source

Committing bonus.ml event if there's still a bug in the drawing of graphical_clip.

master
Quentin Barrand il y a 5 ans
Parent
révision
cf5184297b
1 fichiers modifiés avec 19 ajouts et 23 suppressions
  1. +19
    -23
      src/bonus.ml

+ 19
- 23
src/bonus.ml Voir le fichier

@@ -1,15 +1,6 @@
#use "part4.ml"
#use "simulation1.ml"

(* Question 15 bonus *)

let gen_random_quadtree = fun r n ->
let list = gen_objects_list r n 0 in
quadtree_of_list list r
;;


(* Question 18 bonus *)
let graphical_clip = fun q f ->
@@ -23,27 +14,32 @@ let graphical_clip = fun q f ->
(* Get 2 points *)
let c1 = get_point dparams in
let c2 = get_point dparams in
let r = make_rect c1 c2 in
let r' = make_rect c1 c2 in

(* Debug *)
let _ = Printf.printf "%s\n" (rect_tostring r') in
(* Draw red rectangle and wait for key press *)
let x1 = int_of_float (sx +. z *. rect_left r) in
let y1 = int_of_float (sy +. z *. rect_bottom r) in
let x2 = int_of_float (sx +. z *. rect_right r) in
let y2 = int_of_float (sy +. z *. rect_top r) in
let x1 = int_of_float (sx +. z *. rect_left r') in
let y1 = int_of_float (sy +. z *. rect_bottom r') in
let x2 = int_of_float (sx +. z *. rect_right r') in
let y2 = int_of_float (sy +. z *. rect_top r') in
let _ = Graphics.set_color Graphics.red in
let _ = Graphics.draw_rect x1 y1 (x2-x1) (y2-y1) in
let _ = Graphics.set_color Graphics.black in
(*let _ = Graphics.wait_next_event [ Graphics.Key_pressed ] in*)
let _ = Graphics.wait_next_event [ Graphics.Key_pressed ] in

(* Clip the QuadTree and draw it *)
(* let _ = Graphics.open_graph "" in *)
let _ = Printf.printf "clear_graph" in
let _ = Graphics.clear_graph in
let q' = clip q r in
let _ = simple_test q' (fun str -> str) in
(* let _ = draw_quadtree dparams f q' in *)
let _ = Graphics.close_graph in
let q' = clip q r' in

wait_and_quit ()
let dparams = init r' in
let _ = draw_quadtree dparams f q' in
let _ = wait_and_quit () in
q'
;;

let _ = graphical_clip (gen_random_quadtree (make_rect (0., 0.) (5., 5.)) 20) (fun str -> str) ;;
let q = gen_random_quadtree (make_rect (0., 0.) (30., 30.)) 20 ;;
let qbis = graphical_clip q (fun str -> str) ;;

simple_test qbis (fun str -> str);;

Chargement…
Annuler
Enregistrer