Commits

Barry Schwartz  committed 8341161

Add point <--> complex conversions.

  • Participants
  • Parent commits 1f15cce

Comments (0)

Files changed (2)

File caml2geom.ml

 
   let of_tuple (x,y) = make x y
   let to_tuple p = (coord p 0, coord p 1)
+  let of_complex c = make c.Complex.re c.Complex.im
+  let to_complex p = { Complex.re = coord p 0; Complex.im = coord p 1 }
 end
 
 module Interval =
   external to_array : t -> Point.t array = "bezier_curve_points_wrapper"
   let of_tuple_array tuples = of_array (Array.map Point.of_tuple tuples)
   let to_tuple_array bc = Array.map Point.to_tuple (to_array bc)
+  let of_complex_array complexes = of_array (Array.map Point.of_complex complexes)
+  let to_complex_array bc = Array.map Point.to_complex (to_array bc)
 end
 
 module Line_segment =
   external to_array : t -> Point.t array = "line_segment_points_wrapper"
   let of_tuple_array tuples = of_array (Array.map Point.of_tuple tuples)
   let to_tuple_array bc = Array.map Point.to_tuple (to_array bc)
+  let of_complex_array complexes = of_array (Array.map Point.of_complex complexes)
+  let to_complex_array bc = Array.map Point.to_complex (to_array bc)
 end
 
 module Quadratic_bezier =
   external to_array : t -> Point.t array = "quadratic_bezier_points_wrapper"
   let of_tuple_array tuples = of_array (Array.map Point.of_tuple tuples)
   let to_tuple_array bc = Array.map Point.to_tuple (to_array bc)
+  let of_complex_array complexes = of_array (Array.map Point.of_complex complexes)
+  let to_complex_array bc = Array.map Point.to_complex (to_array bc)
 end
 
 module Cubic_bezier =
   external to_array : t -> Point.t array = "cubic_bezier_points_wrapper"
   let of_tuple_array tuples = of_array (Array.map Point.of_tuple tuples)
   let to_tuple_array bc = Array.map Point.to_tuple (to_array bc)
+  let of_complex_array complexes = of_array (Array.map Point.of_complex complexes)
+  let to_complex_array bc = Array.map Point.to_complex (to_array bc)
 end
 
 module type Path_type =

File caml2geom.mli

 
   val of_tuple : Coord.t * Coord.t -> t
   val to_tuple : t -> Coord.t * Coord.t
+  val of_complex : Complex.t -> t
+  val to_complex : t -> Complex.t
 end
 
 module Interval :
   external to_array : t -> Point.t array = "bezier_curve_points_wrapper"
   val of_tuple_array : (Coord.t * Coord.t) array -> t
   val to_tuple_array : t -> (Coord.t * Coord.t) array
+  val of_complex_array : Complex.t array -> t
+  val to_complex_array : t -> Complex.t array
 end
 
 module Line_segment :
   external to_array : t -> Point.t array = "line_segment_points_wrapper"
   val of_tuple_array : (Coord.t * Coord.t) array -> t
   val to_tuple_array : t -> (Coord.t * Coord.t) array
+  val of_complex_array : Complex.t array -> t
+  val to_complex_array : t -> Complex.t array
 end
 
 module Quadratic_bezier :
   external to_array : t -> Point.t array = "quadratic_bezier_points_wrapper"
   val of_tuple_array : (Coord.t * Coord.t) array -> t
   val to_tuple_array : t -> (Coord.t * Coord.t) array
+  val of_complex_array : Complex.t array -> t
+  val to_complex_array : t -> Complex.t array
 end
 
 module Cubic_bezier :
   external to_array : t -> Point.t array = "cubic_bezier_points_wrapper"
   val of_tuple_array : (Coord.t * Coord.t) array -> t
   val to_tuple_array : t -> (Coord.t * Coord.t) array
+  val of_complex_array : Complex.t array -> t
+  val to_complex_array : t -> Complex.t array
 end
 
 module type Path_type =