Barry Schwartz avatar Barry Schwartz committed 8341161

Add point <--> complex conversions.

Comments (0)

Files changed (2)

 
   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 =
 
   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 =
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.