open Graphics ;; open_graph "" ;; type point_float = {mutable x : float ; mutable y : float } ;; let point = {x = 0.0 ; y = 0.0} ;; let point_courant_float () = (point.x, point.y) ;; let moveto_float x_float y_float = moveto (int_of_float x_float) (int_of_float y_float) ; point.x <- x_float ; point.y <- y_float;; let lineto_float x_float y_float = lineto (int_of_float x_float) (int_of_float y_float) ; point.x <- x_float ; point.y <- y_float ;; let avance distance angle = let (x_courant_float, y_courant_float) = point_courant_float () in let x_cible_float = x_courant_float +. distance *. (cos angle) and y_cible_float = y_courant_float +. distance *. (sin angle) in lineto_float x_cible_float y_cible_float ;; 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 ;; let flocon n distance = clear_graph() ; moveto_float 10. (distance /. 3.) ; motif n distance pi_sur_trois ; motif n distance (-. pi_sur_trois) ; motif n distance (-. pi) ;; clear_graph();; moveto_float 10. 10.;; motif 0 300. 0.;; moveto_float 10. 50.;; motif 1 300. 0.; moveto_float 10. 150.;; motif 2 300. 0.;; moveto_float 10. 250.;; motif 3 300. 0.;; moveto_float 10. 350.;; motif 4 300. 0.;; moveto_float 395. 10. ;; motif 5 300. (pi /. 2.);; moveto_float 490. 10. ;; motif 6 300. (pi /. 2.);; moveto_float 580. 10. ;; motif 7 300. (pi /. 2.);; while not(key_pressed()) do () done;;