2 (* Lissajous
\e$B?^7A
\e(B *)
8 let window = GWindow.window ~border_width: 10 () in
9 window#event#connect#delete
10 ~callback:(fun _ -> prerr_endline "Delete event occured"; true);
11 window#connect#destroy ~callback:Main.quit;
12 let vbx = GPack.vbox ~packing:window#add () in
13 let quit = GButton.button ~label:"Quit" ~packing:vbx#add () in
14 quit#connect#clicked ~callback:window#destroy;
15 let area = GMisc.drawing_area ~width:200 ~height:200 ~packing:vbx#add () in
16 let drawing = area#misc#realize (); new GDraw.drawable (area#misc#window) in
17 let m_pi = acos (-1.) in
20 drawing#set_foreground `WHITE;
21 drawing#rectangle ~filled:true ~x:0 ~y:0 ~width:200 ~height:200 ();
22 drawing#set_foreground `BLACK;
23 (* drawing#line x:0 y:0 x:150 y:150;
24 drawing#polygon filled:true [10,100; 35,35; 100,10; 10, 100];
28 let a = 3 in let b = 5 in
30 let theta0 = 2.*.m_pi*.(float (i-1))/. (float n) in
31 let x0 = 100 + (truncate (r*.sin ((float a)*.theta0))) in
32 let y0 = 100 - (truncate (r*.cos ((float b)*.(theta0+. !c)))) in
33 let theta1 = 2.*.m_pi*.(float i)/.(float n) in
34 let x1 = 100 + (truncate (r*.sin((float a)*.theta1))) in
35 let y1 = 100 - (truncate (r*.cos((float b)*.(theta1+. !c)))) in
36 drawing#line ~x:x0 ~y:y0 ~x:x1 ~y:y1
40 area#event#connect#expose ~callback:expose_event;
41 let timeout _ = c := !c +. 0.01*.m_pi;
44 Timeout.add ~ms:500 ~callback:timeout;
48 let _ = Printexc.print main()