[cairo-commit] cairo-ocaml/test Makefile, 1.3, 1.4 cube.ml, 1.2, 1.3 spline.ml, 1.1.1.1, 1.2 oknockout.ml, 1.1.1.1, NONE

Olivier Andrieu commit at pdx.freedesktop.org
Wed Mar 24 02:39:27 PST 2004


Committed by: oandrieu

Update of /cvs/cairo/cairo-ocaml/test
In directory pdx:/tmp/cvs-serv26488/test

Modified Files:
	Makefile cube.ml spline.ml 
Removed Files:
	oknockout.ml 
Log Message:
removed OO API

Index: Makefile
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/test/Makefile,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** a/Makefile	22 Feb 2004 19:21:08 -0000	1.3
--- b/Makefile	24 Mar 2004 10:39:24 -0000	1.4
***************
*** 3,7 ****
  
  ifdef LABLGTKDIR
! TARGETS += text demo spline basket knockout oknockout
  ifdef GTKCAIRO_CFLAGS
  TARGETS += cube
--- 3,7 ----
  
  ifdef LABLGTKDIR
! TARGETS += text demo spline basket knockout
  ifdef GTKCAIRO_CFLAGS
  TARGETS += cube
***************
*** 29,35 ****
  	$(OCAMLOPT) -w s -o $@ -I ../src -I $(LABLGTKDIR) cairo.cmxa lablgtk.cmxa cairo_lablgtk.cmxa gtkInit.cmx $^
  
- oknockout : oknockout.ml
- 	$(OCAMLOPT) -w s -o $@ -I ../src -I $(LABLGTKDIR) cairo.cmxa lablgtk.cmxa cairo_lablgtk.cmxa gtkInit.cmx $^
- 
  clean :
  	rm -f *.cm* *.o $(TARGETS) *.ps *.ppm *.png
--- 29,32 ----

Index: cube.ml
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/test/cube.ml,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** a/cube.ml	3 Dec 2003 22:17:52 -0000	1.2
--- b/cube.ml	24 Mar 2004 10:39:24 -0000	1.3
***************
*** 4,19 ****
  let initial_size = 200
  
! let redraw w range c =
    let { Gtk.width = width ; Gtk.height = height } =
      w#misc#allocation in
-   let cr = new Ocairo.cairo c in
    let box_size = float (width + height) /. 6. in
!   cr#default_matrix ;
    let off = float width /. 2. in
!   cr#translate off off ;
!   cr#rotate range#adjustment#value ;
!   cr#rectangle (~-. box_size) (~-. box_size) box_size box_size ;
!   cr#set_rgb_color 1. 1. 1. ;
!   cr#fill
  
  let slider_changed cr () =
--- 4,18 ----
  let initial_size = 200
  
! let redraw w range cr =
    let { Gtk.width = width ; Gtk.height = height } =
      w#misc#allocation in
    let box_size = float (width + height) /. 6. in
!   Cairo.default_matrix cr ;
    let off = float width /. 2. in
!   Cairo.translate cr off off ;
!   Cairo.rotate cr range#adjustment#value ;
!   Cairo.rectangle cr (~-. box_size) (~-. box_size) box_size box_size ;
!   Cairo.set_rgb_color cr 1. 1. 1. ;
!   Cairo.fill cr
  
  let slider_changed cr () =
***************
*** 50,54 ****
        ~packing:(b#pack ~expand:true ~fill:true) () in
  
!   let cairo = Ocairo_gtkcairo.cairo 
        ~width:initial_size ~height:initial_size 
        ~packing:f#add () in
--- 49,53 ----
        ~packing:(b#pack ~expand:true ~fill:true) () in
  
!   let cairo = Cairo_gtkcairo.cairo 
        ~width:initial_size ~height:initial_size 
        ~packing:f#add () in

Index: spline.ml
===================================================================
RCS file: /cvs/cairo/cairo-ocaml/test/spline.ml,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** a/spline.ml	18 Nov 2003 19:02:27 -0000	1.1.1.1
--- b/spline.ml	24 Mar 2004 10:39:24 -0000	1.2
***************
*** 1,4 ****
  
! type point = Ocairo.point = 
      { mutable x : float ; 
        mutable y : float }
--- 1,4 ----
  
! type point = Cairo.point = 
      { mutable x : float ; 
        mutable y : float }
***************
*** 9,13 ****
      mutable tolerance  	 : float ;
      mutable line_width 	 : float ;
!             line_cap   	 : Ocairo.line_cap ;
      mutable zoom       	 : float ;
      mutable xtrans     	 : float ;
--- 9,13 ----
      mutable tolerance  	 : float ;
      mutable line_width 	 : float ;
!             line_cap   	 : Cairo.line_cap ;
      mutable zoom       	 : float ;
      mutable xtrans     	 : float ;
***************
*** 45,49 ****
     tolerance = 0.1 ;
     line_width = 10. ; 
!    line_cap = Ocairo.LINE_CAP_ROUND ;
     zoom = 1. ;
     xtrans = 0. ;
--- 45,49 ----
     tolerance = 0.1 ;
     line_width = 10. ; 
!    line_cap = Cairo.LINE_CAP_ROUND ;
     zoom = 1. ;
     xtrans = 0. ;
***************
*** 57,125 ****
  
  
! let draw_control_line ct a b w =
!   ct#save ; begin
!     ct#set_rgb_color 0. 0. 1. ;
!     ct#set_line_width w ;
!     ct#move_to a.x a.y ;
!     ct#line_to b.x b.y ;
!     ct#stroke end ;
!   ct#restore
  
  let two_pi = 8. *. atan 1.
  
! let draw_spline ct spl =
    let drag_pt = { x = spl.drag_pt.x ; y = spl.drag_pt.y } in
!   ct#inverse_transform_point drag_pt ;
!   ct#save ; begin
!     ct#move_to  spl.pt.(0).x spl.pt.(0).y ;
!     ct#curve_to 
        spl.pt.(1).x spl.pt.(1).y 
        spl.pt.(2).x spl.pt.(2).y 
        spl.pt.(3).x spl.pt.(3).y ;
      
!     if spl.click && ct#in_stroke drag_pt.x drag_pt.y
      then spl.active <- 0xf ;
  
!     ct#stroke ;
  
!     draw_control_line ct spl.pt.(0) spl.pt.(1) (2. /. spl.zoom) ;
!     draw_control_line ct spl.pt.(3) spl.pt.(2) (2. /. spl.zoom) ;
  
      for i=0 to 3 do
!       ct#save ; begin
! 	ct#set_rgb_color 1. 0. 0. ;
! 	ct#set_alpha 0.5 ;
! 	ct#new_path ;
! 	ct#arc 
  	  spl.pt.(i).x spl.pt.(i).y
  	  (spl.line_width /. 1.25)
  	  0. two_pi ;
! 	if spl.click && ct#in_fill drag_pt.x drag_pt.y
  	then begin
  	  spl.active <- 1 lsl i ;
  	  spl.click <- false
  	end ;
! 	ct#fill end ;
!       ct#restore
      done end ;
!   ct#restore
  	  
  
  let refresh spl =
!   let ct = Ocairo_lablgtk.cairo ~target:spl.pm#pixmap () in
    spl.pm#rectangle ~x:0 ~y:0 
      ~width:spl.width ~height:spl.height ~filled:true () ;
!   ct#set_rgb_color 0. 0. 0. ;
!   ct#set_line_width spl.line_width ;
!   ct#set_line_cap spl.line_cap ;
!   ct#translate spl.xtrans spl.ytrans ;
!   ct#scale spl.zoom spl.zoom ;
!   ct#set_tolerance spl.tolerance ;
  
!   try draw_spline ct spl
!   with Ocairo.Error _ ->
      prerr_endline "Cairo is unhappy"
  
- 
  let trans_horiz_cb dir spl =
    let delta = float spl.width /. 16. in
--- 57,125 ----
  
  
! 
! let draw_control_line cr a b w =
!   Cairo.save cr ; begin
!     Cairo.set_rgb_color cr 0. 0. 1. ;
!     Cairo.set_line_width cr w ;
!     Cairo.move_to cr a.x a.y ;
!     Cairo.line_to cr b.x b.y ;
!     Cairo.stroke cr end ;
!   Cairo.restore cr
  
  let two_pi = 8. *. atan 1.
  
! let draw_spline cr spl =
    let drag_pt = { x = spl.drag_pt.x ; y = spl.drag_pt.y } in
!   Cairo.inverse_transform_point cr drag_pt ;
!   Cairo.save cr ; begin
!     Cairo.move_to cr  spl.pt.(0).x spl.pt.(0).y ;
!     Cairo.curve_to cr 
        spl.pt.(1).x spl.pt.(1).y 
        spl.pt.(2).x spl.pt.(2).y 
        spl.pt.(3).x spl.pt.(3).y ;
      
!     if spl.click && Cairo.in_stroke cr drag_pt.x drag_pt.y
      then spl.active <- 0xf ;
  
!     Cairo.stroke cr ;
  
!     draw_control_line cr spl.pt.(0) spl.pt.(1) (2. /. spl.zoom) ;
!     draw_control_line cr spl.pt.(3) spl.pt.(2) (2. /. spl.zoom) ;
  
      for i=0 to 3 do
!       Cairo.save cr ; begin
! 	Cairo.set_rgb_color cr 1. 0. 0. ;
! 	Cairo.set_alpha cr 0.5 ;
! 	Cairo.new_path cr ;
! 	Cairo.arc cr 
  	  spl.pt.(i).x spl.pt.(i).y
  	  (spl.line_width /. 1.25)
  	  0. two_pi ;
! 	if spl.click && Cairo.in_fill cr drag_pt.x drag_pt.y
  	then begin
  	  spl.active <- 1 lsl i ;
  	  spl.click <- false
  	end ;
! 	Cairo.fill cr end ;
!       Cairo.restore cr
      done end ;
!   Cairo.restore cr
  	  
  
  let refresh spl =
!   let cr = Cairo_lablgtk.create ~target:spl.pm#pixmap () in
    spl.pm#rectangle ~x:0 ~y:0 
      ~width:spl.width ~height:spl.height ~filled:true () ;
!   Cairo.set_rgb_color cr 0. 0. 0. ;
!   Cairo.set_line_width cr spl.line_width ;
!   Cairo.set_line_cap cr spl.line_cap ;
!   Cairo.translate cr spl.xtrans spl.ytrans ;
!   Cairo.scale cr spl.zoom spl.zoom ;
!   Cairo.set_tolerance cr spl.tolerance ;
  
!   try draw_spline cr spl
!   with Cairo.Error _ ->
      prerr_endline "Cairo is unhappy"
  
  let trans_horiz_cb dir spl =
    let delta = float spl.width /. 16. in

--- oknockout.ml DELETED ---





More information about the cairo-commit mailing list