# -*- Makefile -*-
# Test programs for testing out the cross-compiler.
-all: test1 test1.exe test2 test2.exe
+all: test1 test1.exe test2 test2.exe test3 test3.exe test4 test4.exe
test1: test1.ml
ocamlopt $< -o $@
-test2: test2.ml
- ocamlopt unix.cmxa $< -o $@
-
test1.exe: test1.ml
i686-pc-mingw32-ocamlopt $< -o $@
+test2: test2.ml
+ ocamlopt unix.cmxa $< -o $@
+
test2.exe: test2.ml
i686-pc-mingw32-ocamlopt unix.cmxa $< -o $@
+test3: test3.ml
+ ocamlopt graphics.cmxa $< -o $@
+
+test3.exe: test3.ml
+ i686-pc-mingw32-ocamlopt graphics.cmxa $< -o $@
+
+test4: test4.ml
+ ocamlopt graphics.cmxa $< -o $@
+
+test4.exe: test4.ml
+ i686-pc-mingw32-ocamlopt graphics.cmxa $< -o $@
+
clean:
- rm -f test1 test2 *.exe *.cmi *.cmx *.o
+ rm -f test1 test2 test3 test4 *.exe *.cmi *.cmx *.o
--- /dev/null
+(* From: http://www.ocaml-tutorial.org/the_structure_of_ocaml_programs *)
+
+open Graphics;;
+
+let () =
+ open_graph " 640x480";
+ for i = 12 downto 1 do
+ let radius = i * 20 in
+ set_color (if (i mod 2) = 0 then red else yellow);
+ fill_circle 320 240 radius
+ done;
+ ignore (read_line ())
--- /dev/null
+(* From: http://www.ocaml-tutorial.org/the_structure_of_ocaml_programs *)
+
+let () =
+ Random.self_init ();
+ Graphics.open_graph " 640x480";
+
+ let rec iterate r x_init i =
+ if i = 1 then x_init
+ else
+ let x = iterate r x_init (i-1) in
+ r *. x *. (1.0 -. x)
+ in
+
+ for x = 0 to 639 do
+ let r = 4.0 *. (float_of_int x) /. 640.0 in
+ for i = 0 to 39 do
+ let x_init = Random.float 1.0 in
+ let x_final = iterate r x_init 500 in
+ let y = int_of_float (x_final *. 480.) in
+ Graphics.plot x y
+ done
+ done;
+
+ ignore (read_line ())