let bend = acos (sqrt 0.5) (* unghiul de aplecare, pi/4 *) let rat = 2. (* raportul de micsorare *) let side = 400. (* inaltimea figurii *) let rec treefract x y len phi = let branch phi1 = (* una din cele doua ramuri *) let xn = x +. len *. (cos phi1) (* coordonatele finale ale ramurii *) and yn = y +. len *. (sin phi1) in Printf.printf "M %.1f %.1f L %.1f %.1f " x y xn yn; (* MoveTo LineTo *) treefract xn yn (len /. rat) phi1 (* copac mai mic cu noua orientare *) in if (len > 1.) then ( (* stop la <= 1 pixel *) branch (phi +. bend); branch (phi -. bend); ) let () = ( print_string "<?xml version=\"1.0\"?>\n\ <svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n\ <path stroke=\"blue\" d=\""; (* origine: jos mijloc; segment: 1/2 inaltime; directie: sus = 3*pi/2 *) treefract side side (side /. 2.) (asin (-1.)); print_string "\"/>\n</svg>" )
This document was generated using caml2html