open Graphics ;; open_graph "" ;; let avance distance angle = let (x_courant_int, y_courant_int) = current_point () in let x_courant_float = float_of_int x_courant_int and y_courant_float = float_of_int y_courant_int in let x_cible_float = x_courant_float +. distance *. (cos angle) and y_cible_float = y_courant_float +. distance *. (sin angle) in let x_cible_int = int_of_float x_cible_float and y_cible_int = int_of_float y_cible_float in lineto x_cible_int y_cible_int ;; let pi = 3.1415926535 ;; let pi_sur_trois = pi /. 3. ;; let rec motif generation distance angle = match generation with 0 -> avance distance angle | n -> let nouvelle_distance = distance /. 3. in motif (n-1) nouvelle_distance angle ; motif (n-1) nouvelle_distance (angle +. pi_sur_trois) ; motif (n-1) nouvelle_distance (angle -. pi_sur_trois) ; motif (n-1) nouvelle_distance angle ;; clear_graph();; moveto 10 10;; motif 0 300. 0.;; moveto 10 50;; motif 1 300. 0.; moveto 10 150;; motif 2 300. 0.;; moveto 10 250;; motif 3 300. 0.;; moveto 100 390;; motif 4 300. 0.;; moveto 550 400 ;; motif 5 300. 0.;; while not(key_pressed()) do () done;;