diff options
author | Sébastien Dailly <sebastien@chimrod.com> | 2021-01-05 21:43:08 +0100 |
---|---|---|
committer | Sébastien Dailly <sebastien@chimrod.com> | 2021-01-05 21:43:08 +0100 |
commit | 6ae97ecca8b4f38213f0f45aa6eaef944cd6b497 (patch) | |
tree | 4161c43168fa02f89f4fcf352142d4646d0e980a /path | |
parent | a8f37f041dce3f16917b6659d3ca97492f178f4d (diff) |
Responsive sliders
Diffstat (limited to 'path')
-rwxr-xr-x | path/fixed.ml | 6 | ||||
-rwxr-xr-x | path/fixed.mli | 2 | ||||
-rwxr-xr-x | path/point.ml | 4 | ||||
-rwxr-xr-x | path/point.mli | 4 |
4 files changed, 12 insertions, 4 deletions
diff --git a/path/fixed.ml b/path/fixed.ml index d20c897..7ee0705 100755 --- a/path/fixed.ml +++ b/path/fixed.ml @@ -141,7 +141,7 @@ module Make(Point:P) = struct (** Return the distance between a given point and the curve. May return None if the point is out of the curve *) let distance - : Gg.v2 -> t -> (Gg.v2 * float) option + : Gg.v2 -> t -> (Gg.v2 * float * Point.t * Point.t) option = fun point beziers -> Array.fold_left beziers.path @@ -171,8 +171,8 @@ module Make(Point:P) = struct let _, point' = Shapes.Bezier.get_closest_point point bezier' in let distance = Gg.V2.( norm (point - point') ) in match res with - | None -> Some (point', distance) - | Some (_, d) -> if d < distance then res else (Some (point', distance)) + | None -> Some (point', distance, bezier.p0, bezier.p1) + | Some (_, d, _, _) -> if d < distance then res else (Some (point', distance, bezier.p0, bezier.p1)) end ) diff --git a/path/fixed.mli b/path/fixed.mli index c84b51d..c6af84d 100755 --- a/path/fixed.mli +++ b/path/fixed.mli @@ -38,7 +38,7 @@ module Make(Point:P) : sig (** Return the distance between a given point and the curve. May return None if the point is out of the curve *) val distance - : Gg.v2 -> t -> (Gg.v2 * float) option + : Gg.v2 -> t -> (Gg.v2 * float * Point.t * Point.t) option val map_point : t -> (Point.t -> Point.t) -> t diff --git a/path/point.ml b/path/point.ml index 031e1e0..046c2e7 100755 --- a/path/point.ml +++ b/path/point.ml @@ -25,9 +25,13 @@ let copy point p = let set_angle p angle = { p with angle = Gg.Float.rad_of_deg (180. -. angle) } +let get_angle { angle; _} = 180. -. (Gg.Float.deg_of_rad angle) + let set_width p size = { p with size } +let get_width { size; _} = size + let (+) p1 p2 = { p1 with p = Gg.V2.(+) p1.p p2 } diff --git a/path/point.mli b/path/point.mli index db87a71..c897195 100755 --- a/path/point.mli +++ b/path/point.mli @@ -14,7 +14,11 @@ val copy : t -> Gg.v2 -> t val set_angle : t -> float -> t +val get_angle : t -> float + val set_width: t -> float -> t +val get_width: t -> float + val get_coord' : t -> Gg.v2 |