From 32618a5ce8e2b306af102e4c16711b090c36b840 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Thu, 7 Jan 2021 21:54:46 +0100 Subject: Allow point movement --- path/fixed.mli | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) (limited to 'path/fixed.mli') diff --git a/path/fixed.mli b/path/fixed.mli index 06b3539..2daadb4 100755 --- a/path/fixed.mli +++ b/path/fixed.mli @@ -6,6 +6,8 @@ module type P = sig val id : t -> int + val copy : t -> Gg.v2 -> t + end module Make(Point:P) : sig @@ -32,6 +34,8 @@ module Make(Point:P) : sig val repr : t -> (module Repr.M with type t = Point.t and type repr = 's) -> 's -> 's + (** Structure to represent all the required information for evaluating the + distance between a point and a path *) type approx = { distance : float ; closest_point : Gg.v2 @@ -44,27 +48,38 @@ module Make(Point:P) : sig val distance : Gg.v2 -> t -> approx option + (** Iterate over a path *) val iter : t -> f:(Point.t -> unit) -> unit - val map_point + (** Map all the points in the path *) + val map : t -> (Point.t -> Point.t) -> t + (** Reevaluate all the control points on the path in order to get a smooth + curve *) + val rebuild + : t -> t option + + (** Delete a point in the path. + + Reconnect the path without the point removed, and reevaluate all the + control points from the nodes + + return None if the point is not present in the curve + *) val remove_point - : t -> Point.t -> t + : t -> Point.t -> t option - type bezier = - { p0:Point.t (* The starting point *) - ; p1:Point.t (* The end point *) - ; ctrl0:Gg.v2 (* The control point *) - ; ctrl1:Gg.v2 } (* The control point *) + (** Replace a point by the given one. - type path = - | Line of Point.t * Point.t - | Curve of bezier + An existing point with the same id shall be present in the path. - val path : t -> path array + The path is not fully evaluated, and rebuild shall be runned in order to + get the path completely smooth. - val update : t -> path array -> t + *) + val replace_point + : t -> Point.t -> t option end -- cgit v1.2.3